leetcode 448. 找到所有陣列中消失的數字
阿新 • • 發佈:2021-01-26
orz這個題目我剛開始竟然沒有做出來???震驚!!!
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int>& nums)
{
int len=nums.size();
vector<int> temp(len);
vector<int> res;
for (int i = 0; i <len;i++)
{
temp[ nums[i]-1]=1;
}
for(int j=0;j<len;j++)
{
if(temp[j]==0) res.push_back(j+1);
}
return res;
}
};
現在看來刷題還是有用的嘛,開心.JPG