[C++] simple approach without extra space
follow below steps:\n1. sort the array\n2. If element\'s just above & just after element is not present, then that element is lonely element. just add it in ans
follow below steps:\n1. sort the array\n2. If element\'s just above & just after element is not present, then that element is lonely element. just add it in answer array.\n\n```\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> res;\n        //sort the array\n        sort(nums.begin(), nums.end());\n        //if element\'s just above & just after element is not present\n        //then that element is lonely element.\n        for(int i=0; i<n; i++) {\n            bool flag = true;\n            if(i > 0  && (nums[i-1] + 1 == nums[i] || nums[i-1] == nums[i])) {\n                flag = false;\n            }\n            if(i < n-1 && (nums[i] + 1 ==nums[i+1] || nums[i] == nums[i+1])) {\n                flag = false;\n            }\n            if(flag) {\n                res.push_back(nums[i]);\n            }\n        }\n        return res;\n        \n    }\n};\n```
['C']