Hard
Quiz
#329 Longest Increasing Path in a Matrix
APPROACH
Given an m x n integer matrix, find the longest strictly increasing path. From any cell you may move in four directions: left, right, up, or down. Diagonal moves and wrap-around are not allowed.
Return the length of the longest increasing path in matrix.
Example 1:
Input: matrix = [[9,9,4],[6,6,8],[2,1,1]]
Output: 4
Explanation: The longest increasing path is [1, 2, 6, 9].
Example 2:
Input: matrix = [[3,4,5],[3,2,6],[2,2,1]]
Output: 4
Explanation: The longest increasing path is [3, 4, 5, 6]. Moving diagonally is not allowed.
Example 3:
Input: matrix = [[1]]
Output: 1
1 of 4
1:00
What is the optimal approach for this problem?