Longest Increasing Path in a Matrix

Given an m x n integer matrix, find the length of the longest increasing path in the matrix. From each cell, you can move in four directions: left, right, up, or down. Diagonal movements and wrap-arounds are not permitted.

Constraints

  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m, n <= 200
  • 0 <= matrix[i][j] <= 2^31 - 1
Saving… · 2 lines
class Solution:
def longestIncreasingPath(self, matrix: List[List[int]]) -> int:
Console

Click Run to execute sample tests.