1. 程式人生 > 其它 >leetcode 448. 找到所有陣列中消失的數字

leetcode 448. 找到所有陣列中消失的數字

技術標籤:leetcodeleetcodec++雜湊

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