simple solution | 1ms | single Loop | with explaination
\t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int[][] matrixReshape(int[][] nums, int r, int c) {\n\t\t\t\t\n\t\t\t\tint m = nums.length, n = nums[0].length;\n
\t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int[][] matrixReshape(int[][] nums, int r, int c) {\n\t\t\t\t\n\t\t\t\tint m = nums.length, n = nums[0].length;\n\t\t\t\t\n\t\t\t\tif (r * c != m * n)\n\t\t\t\t\treturn nums;\n\t\t\t\t\t\n\t\t\t\tint[][] reshaped = new int[r][c];\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < r * c; i++)\n\t\t\t\t\treshaped[i/c][i%c] = nums[i/n][i%n];\n\t\t\t\t\t\n\t\t\t\treturn reshaped;\n\t\t\t }\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n#### \t\t\tTime Complexity --> O(N*M)\n#### \t\t\tSpace Complexity --> O(r*c)
['Java']