Java | Steps Broken down & Explained | Short Linear Space & Time Solution | HashMap
Step I:  We are going to use a hashmap to store the frequency of the elements in the given array.\nStep II: Browse the map keys.\nStep III: For each key on the 
**Step I:**  We are going to use a hashmap to store the frequency of the elements in the given array.\n**Step II:** Browse the map keys.\n**Step III:** For each key on the map, we check whether the current key frequency is equal to one, and the consecutive numbers to the given key are not present in the map or not.\n**Step IV:** If the above conditions are satisfied, we add the current key into the ans arraylist.\n\n```\nclass Solution {\n    public List<Integer> findLonely(int[] nums) {\n        List<Integer> ans=new ArrayList<>();\n        if(ans==null || nums.length==0) return ans;\n        \n        HashMap<Integer,Integer> map=new HashMap<>();\n        \n        for(int i=0;i<nums.length;i++){\n            map.put(nums[i],map.getOrDefault(nums[i],0)+1);\n        }\n\n        for(int x:map.keySet()){\n            if(map.get(x)>1 || map.containsKey(x+1) || map.containsKey(x-1)) continue;\n            else ans.add(x);\n        }\n        return ans;\n    }\n}\n```
['Java']