Beats 100%|| 1 ms || easy Java Solution
*mat [ index / no. of column ] [ index % no. of column ]* for both the input and output matrix can be used to insert element \n\nclass Solution {\n    public in
****mat [ index / no. of column ] [ index % no. of column ]**** for both the input and output matrix can be used to insert element \n```\nclass Solution {\n    public int[][] matrixReshape(int[][] mat, int r, int c) {\n        int m=mat.length;\n        int n=mat[0].length;\n        if(r*c!=m*n)\n            return mat;\n        int [][] ans=new int[r][c];\n        for(int i=0;i<r*c;i++)\n            ans[i/c][i%c]=mat[i/n][i%n];\n        return ans;\n    }\n}\n```
['Java']