Shift the rectangular matrix grid to the right k times and return the resulting matrix. During each shift, every value moves one column to the right. A value leaving the last column moves to the first column of the next row; the bottom-right value wraps around to the top-left cell. All moves within one shift happen simultaneously.
Example 1:
Input: grid = [[1,2],[3,4]]
k = 1
Output: [[4,1],[2,3]]Explanation: The values 1 and 3 move right, 2 moves to the start of the next row, and 4 wraps to the top-left corner. The resulting rows are [4, 1] and [2, 3].
Example 2:
Input: grid = [[5,6,7]]
k = 2
Output: [[6,7,5]]Explanation: After one shift the row is [7, 5, 6]. A second shift produces [6, 7, 5].
Example 3:
Input: grid = [[8],[9]]
k = 0
Output: [[8],[9]]Explanation: Zero shifts leave both cells in their original positions, so the matrix is unchanged.
Constraints:
gridis rectangular, with between1and50rows and between1and50columns.-1000 <= grid[i][j] <= 10000 <= k <= 100