Maximum Number of Moves in a Grid | DP | Leetcode 2684