Brute force in c++
class Solution {\npublic:\n    vector findLonely(vector& n) {\n        vectorv2;\n        sort(n.begin(),n.end());\n        long long int k;\n        if(n.size(
class Solution {\npublic:\n    vector<int> findLonely(vector<int>& n) {\n        vector<int>v2;\n        sort(n.begin(),n.end());\n        long long int k;\n        if(n.size()==1)\n           return n;\n        for(int i=0;i<n.size();i++)\n        {\n            k=0;\n            if(i==0)\n            {\n                if((n[i]==n[i+1]) or ((n[i]+1)==n[i+1]))\n                    k++;\n            }\n            else if(i==n.size()-1)\n            {\n                if((n[i]==n[i-1]) or (n[i]==(n[i-1]+1)))\n                    k++;\n            }\n            else\n            {\n                if((n[i]==n[i+1]) or ((n[i]+1)==n[i+1]) or (n[i-1]==n[i]) or ((n[i-1]+1)==n[i]))\n                  k++;\n            }\n            if(k==0){\n                v2.push_back(n[i]);}\n        }\n        return v2;\n    }\n};
[]