Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-around is not allowed).
Example 1
Input: matrix = [[9,9,4],[6,6,8],[2,1,1]]
Output: 4
Explanation: Start at the 1 in the bottom row, move up to 2, up to 6, and up to 9. Each step goes to a strictly larger neighbour, giving a path of length 4.
Example 2
Input: matrix = [[3,4,5],[3,2,6],[2,2,1]]
Output: 4
Explanation: The path 3 → 4 → 5 → 6 moves right along the top row and then down. Each value is larger than the last, giving length 4. Diagonal moves are not allowed.
Example 3
Input: matrix = [[1]]
Output: 1
Explanation: A single cell is a path of length 1.
The longest increasing path starting at a cell depends only on its strictly-greater neighbours, and the grid has no cycles when moving strictly upward — so each cell's answer can be memoized and reused.
Run checks all cases above. Submit evaluates all test cases.