Simple Java Solution with 0ms runtime || Beats 100% 🔥
Stats\n- RunTime: 0ms (Beats 100%)\n\n# Code\npublic int[][] matrixReshape(int[][] mat, int r, int c) {\n    int rows = mat.length, cols = mat[0].length;\n\n   
# Stats\n- **RunTime**: *0ms* (**Beats 100%**)\n\n# Code\npublic int[][] matrixReshape(int[][] mat, int r, int c) {\n    int rows = mat.length, cols = mat[0].length;\n\n    if((r == rows && c == cols) || (rows * cols != r * c)) {\n        return mat;\n    }\n\n    int newMat [][] = new int [r][c], rIndex = 0, cIndex = 0;\n\n    for (int row = 0; row < rows; row++) {\n        for (int col = 0; col < cols; col++) {\n            if(cIndex == c) {\n                rIndex++;\n                cIndex = 0;\n            }\n\n            newMat[rIndex][cIndex++] = mat[row][col];\n        }\n    }\n\n    return newMat;\n}\n```\n<br/>\n<br/>\n<br/>\n\nAuthor :- [*Abhinav Bhardwaj*](https://abhinavbhardwaj.in)
['Java']