FunctionRacerProblemsRace

Heaviest Row

BeginnerGridsPython, JavaScript, TypeScript, Java, C++

Every row of grid has the same number of cells. Add up the numbers in each row and return the index (counting from 0) of the row with the largest total. If several rows share the largest total, return the smallest of their indices.

Example 1

grid [[1,2,3],[4,5,6],[7,8,9]]
returns 2

The row totals are 6, 15 and 24, so row 2 is the heaviest.

Example 2

grid [[5,5],[9,1],[2,8]]
returns 0

All three rows add up to 10, so the smallest index, 0, wins the tie.

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 Grids problems