Java Simple solution with 100%
Code\n\nclass Solution {\n    public int[][] matrixReshape(int[][] mat, int r, int c) {\n        if (mat.length * mat[0].length != r * c) return mat;\n\n       
# Code\n```\nclass Solution {\n    public int[][] matrixReshape(int[][] mat, int r, int c) {\n        if (mat.length * mat[0].length != r * c) return mat;\n\n        int[][] arr = new int[r][c];\n        int k = 0, l = 0;\n        for (int i = 0; i < mat.length; i++) {\n            for (int j = 0; j < mat[i].length; j++) {\n                arr[k][l] = mat[i][j];\n                l++;\n                if (l == c) {\n                    l = 0;\n                    k++;\n                }\n            }\n        }\n\n        return arr;\n    }\n}\n```
['Java']