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