1ms in java very easy code
Code
![94da60ee-7268-414c-b977-2403d3530840_1725903127.9303432.png](https://assets.leetcode.com/users/images/1b84e714-862e-4a2f-bc34-9f1a85568f66_1734850700.5907803.png)
![94da60ee-7268-414c-b977-2403d3530840_1725903127.9303432.png](https://assets.leetcode.com/users/images/a9599198-d6f9-424f-a840-9565431cb7c9_1734850700.3893743.png)


# Code
```java []
class Solution {
    public int[][] matrixReshape(int[][] mat, int r, int c) {
        if (mat.length * mat[0].length != r * c) {
            return mat;
        }
        int[][] output = new int[r][c];
        for (int i = 0; i < r * c; i++) {
        output[i / c][i % c] = mat[i / mat[0].length][i % mat[0].length];
        }
        return output;    
    }
}
```
['Java']