✅O(M*N) || Single For loop || Easy-understanding
\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        int m = size(mat), n = size(mat[0]), total
```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        int m = size(mat), n = size(mat[0]), total = m * n;\n        if(r * c != total) return mat;\n        vector<vector<int>> ans(r, vector<int>(c));\n        for(int i = 0; i < total; i++) \n            ans[i / c][i % c] = mat[i / n][i % n];\n        return ans;\n    }\n};\n```
['C', 'Matrix']