Apple interview question

standard 2d dp leetcode problem