Hard · Matrices
Longest increasing path
Given an m × n integer matrix mat, return the length of the longest path whose values strictly increase, where each step moves to the cell directly above, below, left or right (no diagonal moves, no wrap-around).
Examples
Example 1
[[9,9,4],[6,6,8],[2,1,1]]Output: length 4
Example 2
[[3,4,5],[3,2,6],[2,2,1]]Output: length 4
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.