218. Longest Increasing Path in a Matrix

HardDynamic Programming

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).

Examples

Input: [[9,9,4],[6,6,8],[2,1,1]]

Output: 4

Explanation: The increasing path 1 → 2 → 6 → 9 has length 4.

Constraints

  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m, n <= 200
  • 0 <= matrix[i][j] <= 2^31 - 1
Loading...

Run checks all cases above. Submit evaluates all test cases.