Apple Interview Question

standard 2d dp leetcode problem