329. Longest Increasing Path In a Matrix

Practice Longest Increasing Path In a Matrix for free on NudgeCode: Hard, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the length of the longest path in matrix where each step moves to a cell directly up, down, left or right and every step lands on a strictly larger value. Diagonal moves and wrapping around the edges are not allowed. A single cell is a path of length 1.

Example

matrix = [[9,9,4],
          [6,6,8],
          [2,1,1]]   ->  4   (1 -> 2 -> 6 -> 9)
matrix = [[1]]       ->  1

Constraints