Column Totals
Every row of grid has the same length. Return a list with one entry per column, from the leftmost column to the rightmost: the sum of all the numbers in that column.
Example 1
grid [[1,2,3],[4,5,6]]
returns [5,7,9]
Column 0 holds 1 and 4, column 1 holds 2 and 5, column 2 holds 3 and 6.
Example 2
grid [[-1,4],[3,-4],[2,0]]
returns [4,0]
The second column adds up to 4 - 4 + 0 = 0.
Constraints
1 <= rows, cols <= 10-100 <= grid[r][c] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Grids problems
- Count Negatives in a Sorted GridBeginner
- Cross TotalBeginner
- Enlarge the PictureBeginner
- Frame TotalBeginner
- Heaviest RowBeginner
- Layer LabelsBeginner
- Mirror the RowsBeginner
- Rising DiagonalBeginner