Java. Arrays. Matrix reshape
\n\nclass Solution {\n    public int[][] matrixReshape(int[][] mat, int r, int c) {\n        if (mat.length * mat[0].length != r * c)\n            return mat;\n
\n```\nclass Solution {\n    public int[][] matrixReshape(int[][] mat, int r, int c) {\n        if (mat.length * mat[0].length != r * c)\n            return mat;\n        int[][] answ = new int[r][c];\n        for(int i = 0; i < r * c; i++)\n            answ[i / c][i % c] = mat[i / mat[0].length][i % mat[0].length];\n        return answ;\n    }\n}\n```
['Java']