Longest Increasing Matrix Path Problem

Longest Increasing Matrix Path Problem — ExecCode Hard DSA Practice

Solve the Longest Increasing Matrix Path problem on ExecCode. Free online hard DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.

Problem description

From any cell you may walk 4-directionally to a strictly greater neighbor. Find the longest such path (count cells). Return the number of cells on a longest increasing path. You are given: matrix — integers, duplicates allowed Return integer length >= 1. A single cell is a path of length 1.

Examples

Input {'matrix': [[9, 9, 4], [6, 6, 8], [2, 1, 1]]}; Output 4. Input {'matrix': [[3, 4, 5], [3, 2, 6], [2, 2, 1]]}; Output 4. Input {'matrix': [[1]]}; Output 1

Constraints

Strictly increasing You may start anywhere

Practice Longest Increasing Matrix Path free on ExecCode. Browse DSA problems, topic map, and placement guides.