C++ || 98.54% solution
Runtime: 16 ms, faster than 98.54% of C++ online submissions for Reshape the Matrix.\nMemory Usage: 11.3 MB, less than 77.01% of C++ online submissions for Resh
***Runtime: 16 ms, faster than 98.54% of C++ online submissions for Reshape the Matrix.\nMemory Usage: 11.3 MB, less than 77.01% of C++ online submissions for Reshape the Matrix.***\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) {\n        int rows = nums.size();\n        int cols = nums[0].size();\n        if(rows * cols != r * c || ( rows == r && cols == c)){\n            return nums;\n        }\n        vector<vector<int>> result(r,vector<int>(c,0));\n        int current = 0;\n        for(int i=0;i<r;i++){\n            for(int j=0;j<c;j++){\n                int x = current / cols;\n                int y = current % cols;\n                result[i][j] = nums[x][y];\n                current ++;\n            }\n        }\n        return result;\n    }\n};\n```\n\n
['C', 'C++']