Longest Increasing Path in a 2D Matrix Problem Statement
Given a matrix of non-negative integers of size 'N x M', where 'N' and 'M' denote the number of rows and columns respectively, find the length of the longest increasing path. You can move in any of the four directions: left, right, up, or down from each cell. Diagonal movement or moving outside the boundary of the matrix is not allowed.
Example:
Input:
3 2
2 2
5 6
6 9
5 11
Output:
3
Explanation:
In the given matrix, sequences like 3 → 5 → 6 and 3 → 5 → 9 form increasing paths of length 3 each.
Constraints:
- 1 <= T <= 100
- 1 <= N <= 50
- 1 <= M <= 50
- 0 <= MATRIX[i] <= 105
Note:
You do not need to print anything; it has already been taken care of. Just implement the function.
The task is to find the length of the longest increasing path in a 2D matrix, where you can move in four directions: left, right, up, or down from each cell.
Traverse the matrix and for each cell, find...read more
Top Facebook Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Facebook Software Developer
Reviews
Interviews
Salaries
Users/Month