TWO EASY C++ APPROACHES 
Complexity
Time complexity:O(n)

Space complexity:O(n)
Code

# Complexity
- Time complexity:O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<int> findLonely(vector<int>& nums) {
     /*  int n=nums.size();
       unordered_map<int, int>mpp;
       vector<int>ans;
       for(int i=0;i<n;i++){
        mpp[nums[i]]++;
       }
       for(int i:nums){
        if(mpp.find(i-1)==mpp.end() && mpp.find(i+1)==mpp.end() && mpp[i]==1)ans.push_back(i);
       }
       return ans;*/


       int count[1000001]={0};
       vector<int>ans;
       for(int num:nums)count[num]++;
       for(int num:nums){
        if(count[num]==1 && (num==0|| count[num-1]==0) && (num==1000000 ||count[num+1]==0))ans.push_back(num);
       }
       return ans;
    }
};
```
['C++']