Java in one pass ,faster than 100%
Please UpVote if you like the solution Happy Coding !!!\n\nclass Solution {\n    public int[][] matrixReshape(int[][] nums, int r, int c) {\n    int m = nums.le
*Please **UpVote** if you like the solution **Happy Coding** !!!*\n```\nclass Solution {\n    public int[][] matrixReshape(int[][] nums, int r, int c) {\n    int m = nums.length, n = nums[0].length;\n    if (r * c != m * n)\n        return nums;\n    int[][] reshaped = new int[r][c];\n    for (int i = 0; i < r * c; i++)\n        reshaped[i/c][i%c] = nums[i/n][i%n];\n    return reshaped;\n }\n}\n```
['Java']