As reported: DoorDash E4 phone screen (USA, 2025, passed): LeetCode 329, reworded with dashers but otherwise unchanged. The code had to actually run. Follow-up: track and return the path itself.
This is LeetCode 329 — Longest Increasing Path in a Matrix.
Given an m x n integer matrix, return the length of the longest strictly increasing path. From each cell you can move up, down, left or right; you may not move diagonally or outside the matrix.
Example 1
matrix = [[9,9,4],[6,6,8],[2,1,1]]
Output: 4
The path [1, 2, 6, 9].
Example 2
matrix = [[3,4,5],[3,2,6],[2,2,1]]
Output: 4
The path [3, 4, 5, 6].
Example 3
matrix = [[1]]
Output: 1
Constraints: 1 ≤ m, n ≤ 200; 0 ≤ matrix[i][j] ≤ 2^31 − 1.
Follow-ups
- Return the path itself, not only its length.
Code runner format: one JSON value per line: matrix. Implement longestIncreasingPath(matrix); the harness prints the answer.