Corner Column Sum
EasyP3Coding
Return the sum of all elements in the first column and the last column of an N x M matrix. If the matrix has a single column, that column is counted once.
Example 1
- Input
- matrix = [[1,2,3],[4,5,6]]
- Output
- 14
Example 2
- Input
- matrix = [[1,2],[3,4]]
- Output
- 10
Example 3
- Input
- matrix = [[5]]
- Output
- 5
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.