Facebook | Phone Screen | SDE
Anonymous User
1275

Given a matrix of size m x n,
Find the longest path in the matrix from (0, 0) to (m, n).

You can move in 4 directions, up, down, left right.
Visit each (i, j) once only.
n, m <= 10^5

Example, for 3x3 => Ans: 8. (don't count (0, 0))
Example, for 2x2 => Ans: 2. (don't count (0, 0))

Comments (3)