Search⌘ K
AI Features

Longest Increasing Path in a Matrix

Try to solve the Longest Increasing Path in a Matrix problem.

Statement

You are given an m×nm × n matrix of integers. Your task is to determine the length of the longest strictly increasing path within the matrix.

A path is defined by consecutively moving from one cell to another adjacent cell. From any cell, movement is allowed only in four directions: up, down, left and right.

Diagonal movement is not allowed. You also cannot move outside the matrix boundaries (no wrap-around).

A path is considered increasing if each ...