Beats 100% || Simple and easy to understand || C++
\n\n# Code\n\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        int m = mat.size() , n= mat[0]
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        int m = mat.size() , n= mat[0].size();\n        vector<vector<int>>v(r,vector<int>(c));\n        queue<int>q;\n        if(m*n == r*c){\n            for(int i=0;i<m;i++){\n                for(int j=0;j<n;j++){\n                    q.push(mat[i][j]);\n                }\n            }\n            for(int i=0;i<r;i++){\n                for(int j=0;j<c;j++){\n                    v[i][j] = q.front();\n                    q.pop();\n                }\n            }\n            return v;\n        }\n        return mat;\n    }\n};\n```
['C++']