Hard · Matrices
Longest Increasing Path in a Matrix (Matrices)
Given an m × n integer matrix, return the length of the longest strictly increasing path in it, where each step moves to an adjacent cell up, down, left or right (diagonal moves and wrapping around the border are not allowed).
Examples
Example 1
[[9,9,4],[6,6,8],[2,1,1]] → 4Output: longest path = 4
Example 2
[[3,4,5],[3,2,6],[2,2,1]] → 4Output: longest path = 4
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.