C++ easy implementation
\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        vector<vector<int>> vc(r,vector<int>(c));\
```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        vector<vector<int>> vc(r,vector<int>(c));\n        if((r*c)!=(mat.size()*mat[0].size())) return mat;\n        vector<int> y;\n        for(int p=0;p<mat.size();p++){\n            for(int q=0;q<mat[0].size();q++){\n                y.push_back(mat[p][q]);\n            }\n        }       \n        auto it = y.begin();\n        for(int i=0;i<r;i++){\n            for(int j = 0;j<c;j++){\n                vc[i][j]=*it;\n                it++;\n            }\n        }\n        return vc;\n    }\n};\n```
['C', 'Iterator']