Java | O(n) | HashMap | Easy
\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        List<Integer> ans = new ArrayList();\n        HashMap<Integer, Integer> s = new H
```\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        List<Integer> ans = new ArrayList();\n        HashMap<Integer, Integer> s = new HashMap();\n        for (int i: nums) {\n            s.put(i, s.getOrDefault(i, 0) + 1);\n        }\n        \n        for (int i: nums) {\n            if (s.get(i) == 1 && !s.containsKey(i+1) && !s.containsKey(i-1)) ans.add(i);\n        }\n        \n        return ans;\n    }\n}\n```
['Java']