where is wrong ,my submit of No.566


  • 0
    H

    class Solution {
    public:
    vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) {
    vector<int> tmp;
    for(int i=0;i<nums.size();i++)
    {
    for(int j=0;j<nums[i].size();j++)
    {
    tmp.push_back(nums[i][j]);
    }
    }
    if(tmp.size()==r*c)
    {
    int t=0;
    vector<vector<int>> ans;
    for(int i=0;i<r;i++)
    {
    for(int j=0;j<c;j++)
    {
    ans[i].push_back(tmp[t++]);
    }
    }
    return ans;
    }
    else
    {
    return nums;
    }
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.