JAVA - HashMap Solution / Easy to Understand
\npublic int findPairs(int[] nums, int k) {\n\tif(nums == null || nums.length == 0 || k<0) return 0;\n\tint count = 0;\n\tHashMap<Integer, Integer> hm = new Has
```\npublic int findPairs(int[] nums, int k) {\n\tif(nums == null || nums.length == 0 || k<0) return 0;\n\tint count = 0;\n\tHashMap<Integer, Integer> hm = new HashMap<>();\n\tfor(int num : nums) \n\t\thm.put(num, hm.getOrDefault(num, 0)+1);\n\tfor(Map.Entry<Integer, Integer> e : hm.entrySet())\n\t\tif(k==0 && e.getValue()>=2) count++;\n\t\telse if(k!=0 && hm.containsKey(e.getKey()+k)) count++;\n\treturn count;\n}\n```
[]