Shift 2D Grid
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an m x n integer matrix grid and an integer k. One **shift** moves every element
one step forward in row-major order: grid[i][j] moves to grid[i][j+1], the last element of a row
moves to the first column of the next row, and the very last element grid[m-1][n-1] wraps around to
grid[0][0].
Apply the shift k times and return the resulting grid (same dimensions).
Examples
Constraints
- m == grid.length
- n == grid[i].length
- 1 <= m, n <= 50
- -1000 <= grid[i][j] <= 1000
- 0 <= k <= 100
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.