01 · Question
Given a rectangular integer grid, return the largest sum on a path from its top-left to bottom-right cell, moving only right or down. Include both endpoints; values may be negative. An empty grid returns zero.
Example: [[1,-2],[3,4]] returns 8.
02 · Analysis
dp[r][c] is the best path sum ending at that cell. The preceding cell is either above or left, so take the better reachable predecessor and add the current value. Initialize the first row and column from their only legal predecessor rather than using zero for an illegal move; this handles negative grids. Fill row by row in O(RC) time and O(RC) auxiliary space. A rolling row reduces space to O(C) if only the value is required; store predecessor decisions if a path is required.