Clear | Easy | HashMap ✅
\n# Code\n\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        HashMap<Integer, Integer> map=new HashMap<>();\n        for(int i=0; i<
\n# Code\n```\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        HashMap<Integer, Integer> map=new HashMap<>();\n        for(int i=0; i<nums.length; i++){\n            if(map.containsKey(nums[i])){\n                map.put(nums[i],map.get(nums[i])+1);\n            }else{\n                map.put(nums[i],1);\n            }\n        }\n        List<Integer> ans=new ArrayList<>();\n        for(Integer 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```\n\n______________________________________\n\n**Up Vote if Helps**![image.png](https://assets.leetcode.com/users/images/23d8443e-ac59-49d5-99f0-9273a2147be2_1687635435.0337658.png)\n\n______________________________________
['Array', 'Hash Function', 'Java']