Given a 2D array of integers, this problem looks for the longest path from the top left to the bottom right where each step only visits cells with values greater than or equal to the current cell.
The candidate's solution is complete and solves the problem. The approach is to use dynamic programming. The idea is to create a 2D array of the same size as the input array. The value of each cell in the 2D array is the length of the longest path from the top left to that cell. The value of the top left cell is 1. The value of the other cells is the maximum of the value of the cell above and the value of the cell to the left, plus 1. The value of the bottom right cell is the length of the longest path. The time complexity is O(n^2) and the space complexity is O(n^2).
Evaluated at: 2022-10-11 01:04:57