C++ || Two Methods || Space Optimised
\n\n// 1. Using Mapping , SC : O(n) , TC : O(n)\n\n\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& nums) {\n        \n          vector<int>
```\n\n// 1. Using Mapping , SC : O(n) , TC : O(n)\n\n\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& nums) {\n        \n          vector<int> ans;\n        unordered_map<int, int> mp;\n        \n        for(auto i : nums)\n            mp[i]++;\n        \n        for(auto i : mp)\n        {\n            if(i.second == 1)\n            {\n                if(mp.find(i.first-1) == mp.end() && mp.find(i.first+1) == mp.end())\n                    ans.push_back(i.first);\n            }\n        }\n        \n        return ans;\n    }\n};\n\n\n// 2. Without Maping  , SC : O(1)  , TC : (O(NLog(n))\n\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& nums) {\n        \n        vector<int> ans;\n        sort(nums.begin() , nums.end());\n        \n        nums.insert(nums.begin() , -100);\n        nums.push_back(10000000);\n        \n        for(int i = 1 ; i <nums.size()-1 ; i++)\n        {\n            if(nums[i]-nums[i-1] > 1 && nums[i+1]-nums[i] > 1)\n                ans.push_back(nums[i]);\n        }\n        \n        return ans;\n        \n        \n    }\n};\n```
['C', 'Sorting']