Easy Solution Using C++
```\nclass Solution {\npublic:\n    vector> matrixReshape(vector>& mat, int r, int c) {\n        vectormatri;\n        int m=mat.size(), n=mat[0].size();\n\t\t 
```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        vector<int>matri;\n        int m=mat.size(), n=mat[0].size();\n\t\t    if(r*c !=m*n){\n            return mat;\n        }\n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                matri.push_back(mat[i][j]);\n            }\n        }\n    \n        vector<vector<int>>ans(r, vector<int>(c,0));\n        int k=0;\n        for(int i=0;i<r;i++){\n            for(int j=0;j<c;j++){\n                ans[i][j]=matri[k];\n                k++;\n            }\n        }\n        return ans;\n    }\n};\n//If the solution helped you then dont forget to upvote!!
['C']