#include using namespace std; class Solution { public: vector> shiftGrid(vector> &grid, int k) { int n = grid.size(), m = grid[0].size(); vector> ans(n, vector(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int newJ = (j + k) % m; int newI = (i + (j + k) / m) % n; ans[newI][newJ] = grid[i][j]; } return ans; } }; int main() {}