Java HashMap
Complexity\nTime O(n)\nSpace O(n)\n\n Iterating over the map could be better becase of the duplicates in the nums array, thanks @indianpie.\n\npublic List<Integ
Complexity\nTime O(n)\nSpace O(n)\n\n Iterating over the map could be better becase of the duplicates in the nums array, thanks @indianpie.\n```\npublic List<Integer> findLonely(int[] nums) {\n        Map<Integer, Integer> map = new HashMap<>();\n        for (int num : nums) {\n            map.put(num, map.getOrDefault(num, 0) + 1);\n        }\n        List<Integer> res = new ArrayList<>();\n\t\tfor (int num : map.keySet()) {\n       //  for (int num : nums) {\n            if (map.get(num) == 1 && !map.containsKey(num - 1) && !map.containsKey(num + 1)) {\n                res.add(num);\n            }\n        }\n        return res;\n    }\n```
['Java']