Find maximum sum rectangle in a D (two-dimensional) grid. This combines D (one-dimensional) max subarray with column enumeration. Fix top and bottom rows. Compress columns to 1D array (sum of elements between rows). Apply Kadane's algorithm. With constraint that rectangle width : use sliding window maximum instead of Kadane. Time:
Time complexity: for basic. With width constraint: using monotonic queue for columns.
Space complexity: for the prefix sums.