Approach hintTry it first, then revealHide
A path visits n + m - 1 cells, so that count must be even. Compute the minimum and maximum path sums with two grid DPs, then consider how the sum changes when a path is bent into a neighbouring one.
A path visits n + m - 1 cells, so that count must be even. Compute the minimum and maximum path sums with two grid DPs, then consider how the sum changes when a path is bent into a neighbouring one.