Even Sum in Columns
EasyP3Coding
For each column of an N x M matrix, compute the sum of the even elements in that column (0 if there are none). Return the M sums, from the first column to the last.
Example 1
- Input
- matrix = [[1,2,3],[4,5,6]]
- Output
- [4,2,6]
Example 2
- Input
- matrix = [[2,4],[6,8]]
- Output
- [8,12]
Example 3
- Input
- matrix = [[1,3],[5,7]]
- Output
- [0,0]
Constraints
- 1 <= N, M <= 100
- -10^4 <= matrix[i][j] <= 10^4
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.