FunctionRacerProblemsRace

Best Square Block

HardNumPyPython

Return [r, c]: the top-left cell of the k by k block of grid with the largest sum. If blocks tie, return the first in reading order (top row first, then leftmost). No loops: for and while are not allowed.

Example 1

grid [[1,2,0],[3,4,0],[0,0,9]]
k 2
returns [1,1]

The block with rows 1 to 2 and columns 1 to 2 holds 4, 0, 0 and 9: 13, the largest sum.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems