C++ & Python | Easy to understand | O(n) | Simple, Clean, Explained
Approach:\nHashmaps are the most convenient way since we are dealing with frequencies of more than one element. The definition of a lonely number x requires us 
### Approach:\nHashmaps are the most convenient way since we are dealing with frequencies of more than one element. The definition of a lonely number `x` requires us to check:\n1. the presence of `x - 1` and `x + 1`  -> frequency of `x - 1` and `x + 1` = 0\n2. whether frequency of `x` in the array to be **exactly 1**.\n\nHence, the steps are as follows:\n- Record frequencies of all the elements in the array\n- Iterate through the array and check for the conditions 1 and 2 above.\n- If condition is met, we append it to the result array\n\n#### C++ Solution\n```\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& nums) {\n        unordered_map<int, int> freq;\n        vector<int> lonelies;\n\t\t\n        for (int i = 0; i < nums.size(); i++) {\n            freq[nums[i]]++;\n        }\n        \n        for (int i = 0; i < nums.size(); i++) {\n            if (freq[nums[i] - 1] == 0 && freq[nums[i]] == 1 && freq[nums[i] + 1] == 0) {\n                lonelies.push_back(nums[i]);\n            }\n        }\n        \n        return lonelies;\n    }\n};\n```\n\n#### Python Solution\n```\nclass Solution:\n    def findLonely(self, nums: List[int]) -> List[int]:\n        freq = dict()\n        result = []\n        \n        for n in nums:\n            freq[n] = freq.get(n, 0) + 1\n            \n        for n in nums:\n            if freq.get(n - 1, 0) == 0 and freq.get(n, 0) == 1 and freq.get(n + 1, 0) == 0:\n                result.append(n)\n        \n        return result\n```
['C', 'Python', 'Python3']