C++ Hash Map O(N)
See my latest update in repo LeetCode\n\n\n## Solution 1. Hash Map\n\ncpp\n// OJ: https://leetcode.com/contest/weekly-contest-277/problems/find-all-lonely-numbe
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n\n## Solution 1. Hash Map\n\n```cpp\n// OJ: https://leetcode.com/contest/weekly-contest-277/problems/find-all-lonely-numbers-in-the-array/\n// Author: github.com/lzl124631x\n// Time: O(N)\n// Space: O(U) where U is the number of unique elements in `A`\nclass Solution {\npublic:\n    vector<int> findLonely(vector<int>& A) {\n        unordered_map<int, int> m;\n        for (int n : A) m[n]++;\n        vector<int> ans;\n        for (int n : A) {\n            if (m[n] == 1 && m.count(n + 1) == 0 && m.count(n - 1) == 0) {\n                ans.push_back(n);\n            }\n        }\n        return ans;\n    }\n};\n```
[]