一 问题
二哒哒
/**
* @param {number[][]} grid
* @param {number} k
* @return {number[][]}
*/
var shiftGrid = function(grid, k) {
var ans = [];
let n = grid.length;
let m = grid[0].length;
for(let i = 0; i < n; i++) {
for(let j = 0; j < m; j++) {
let new_i = (i + Math.floor((j + k) / m)) % n;
let new_j = (j + k) % m;
ans[new_i] = ans[new_i] == undefined ? [] : ans[new_i];
ans[new_i][new_j] = grid[i][j];
}
}
return ans;
};
ww