C++ easy solution || without converting to 1-D array || beginner friendly
Please upvote if you find it helpful :)\n\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        i
*Please **upvote** if you find it helpful :)*\n```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        int mr = mat.size();\n        int nc = mat[0].size();\n        vector<vector<int> > ans;\n        if(mr*nc != r*c)\n            return mat;\n        int k=0,l=0;\n        for(int i=0;i<r;i++) {\n            vector<int> v;\n            for(int j=0;j<c;j++) {\n                v.push_back(mat[k][l]);\n                l++;\n                if(l>=nc) {\n                    k++;\n                    l=0;\n                }\n            }\n            ans.push_back(v);\n        }\n        return ans;\n    }\n};\n```
['Array', 'C']