Google·Software Engineer·Onsite - Coding / Algorithms
- Given an m x n integer grid, find the longest path starting from any cell where each move goes to an adjacent cell (4 directions) and the value is non-increasing, except that each step can also compare against the value two cells back (not just the immediately previous cell). Return the number of cells visited on the longest valid path.
“The base idea looks like a standard longest decreasing path on a grid, which I've seen before, so I jumped into memoized DFS pretty fast.”