C++ simple solution


  • 0
    Y
    class Solution {
    public:
        vector<int> findDisappearedNumbers(vector<int>& nums) {
            set<int> nums_set(nums.begin(), nums.end());
            vector<int> result;
            for(int i = 1; i<=nums.size();i++){
                if(nums_set.count(i)==0)
                    result.push_back(i);
            }
            return result;
        }
    };
    

Log in to reply
 

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