class Solution {
public:
vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {
vector<int> temp;
for(auto x :mat)
{
for(auto ch : x)
{
temp.push_back(ch);
}
}
if(temp.size() != r * c) return mat;
else{
vector<vector<int>> res;
for(int i = 1;i<=r;i++)
{
vector<int> v;
for(int j = (i-1)*c;j< c*i;j++)
{
v.push_back(temp[j]);
}
res.push_back(v);
}
return res;
}
}
};