Longest Climb
heights[r][c] is the height of each cell of a hillside. A climb starts in any cell and moves up, down, left or right, each time onto a cell that is strictly higher than the one before.
Return the number of cells on the longest climb.
Example 1
heights [[1,2,3],[6,5,4],[7,8,9]]
returns 9
The climb 1, 2, 3, 4, 5, 6, 7, 8, 9 winds through every cell.
Example 2
heights [[5,5],[5,5]]
returns 1
No cell is higher than its neighbor, so a climb is a single cell.
Example 3
heights [[7,2,3],[1,9,4],[8,6,5]]
returns 6
One longest climb is 2, 3, 4, 5, 6, 8.
Constraints
1 <= len(heights) <= 12and1 <= len(heights[0]) <= 120 <= heights[r][c] <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.