This question evaluates mastery of graph traversal, dynamic programming, and complexity analysis for computing longest increasing paths in a matrix, focusing on algorithmic correctness and efficient use of time and space.

Given an m×n grid of integers, find the length of the longest path where each step moves up, down, left, or right to a strictly larger value. Return the maximum length over all starting cells. Design an O(mn) solution using memoized DFS or an equivalent iterative/topological approach, and analyze time and space usage. As a follow-up, discuss handling very large grids, recursion-depth limits, and variants such as allowing non-decreasing steps or diagonal moves.