Java Concise O(nm) time
\npublic int[][] matrixReshape(int[][] nums, int r, int c) {\n    int n = nums.length, m = nums[0].length;\n    if (r*c != n*m) return nums;\n    int[][] res = 
```\npublic int[][] matrixReshape(int[][] nums, int r, int c) {\n    int n = nums.length, m = nums[0].length;\n    if (r*c != n*m) return nums;\n    int[][] res = new int[r][c];\n    for (int i=0;i<r*c;i++) \n        res[i/c][i%c] = nums[i/m][i%m];\n    return res;\n}\n```
[]