Code RoomMaximum subgrid sum
MediumPrep Room Coding #484

Maximum subgrid sum

CodingAlgorithms & data structuresEntry–Mid~16 min

A hospital floor is mapped as a grid where each cell holds the number of patient interactions logged in that zone this week. Facilities wants to place a supply station covering an h-by-w block of zones (h rows by w columns, axis-aligned) where the block's total interactions are highest. Given the non-empty grid and integers h and w (guaranteed to fit inside the grid), return the maximum block total. Cell values may be negative for closed zones. Example: grid = [[1, 2, 3], [4, 5, 6]], h = 1, w = 2 gives 11.

Implement
busiest_block(grid: list[list[int]], h: int, w: int) → int
Examples
in[[[1,2,3],[4,5,6]],1,2]out11
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
[[[1,2,3],[4,5,6]],1,2]11not run yetsample