11 ms, faster than 70.37% of C++ online submissions
\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        \n         if( mat.size() * mat[0].size() 
```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n        \n         if( mat.size() * mat[0].size() != r*c)\n            return mat;\n        \n        vector<vector<int>>ans(r,vector<int>(c));\n        \n        int row=0, col =0;\n        \n        for( int i = 0 ; i <mat.size() ; i++ ){\n            \n            for( int j = 0 ; j < mat[0].size() ; j++ ){\n                \n                if( col == c ){\n                    row++;\n                    col=0;\n                }\n                 ans[row][col] = mat[i][j];\n                col++;\n            }\n        }\n        return ans;\n    }\n};\n```\n\n**PLEASE UPVOTE IF THIS SOLUTION IS HELPFUL FOR YOU**
['C++']