Given a rectangular grid of integers grid (a list of rows), return a list of two lists:
the sum of every row, and the sum of every column, in that order.
Examples
Input: grid = [[1, 2, 3],
[4, 5, 6]]
Output: [[6, 15], [5, 7, 9]]
Explanation: row totals are 6 and 15; column totals are 5, 7 and 9.
Input: grid = [[4]]
Output: [[4], [4]]
Constraints
1 <= rows, cols <= 100, all rows have the same length-1000 <= grid[r][c] <= 1000
Goals
- Iterate over rows and over columns of a 2D list
- Build two result lists in one function