Increment Matrix Elements
EasyP3Coding
Return a new N x M matrix in which every element of matrix is increased by one. Do not change the input matrix.
Example 1
- Input
- matrix = [[1,2,3],[4,5,6]]
- Output
- [[2,3,4],[5,6,7]]
Example 2
- Input
- matrix = [[0]]
- Output
- [[1]]
Example 3
- Input
- matrix = [[-1,-2],[-3,-4]]
- Output
- [[0,-1],[-2,-3]]
Constraints
- 1 <= N, M <= 100
- -10^9 <= matrix[i][j] <= 10^9 - 1
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.