easy java solution, two HashSets O(n)
\nclass Solution {\n    public int findPairs(int[] nums, int k) {\n        if (k < 0) return 0;\n        Set<Integer> numbers = new HashSet<>();\n        Set<In
```\nclass Solution {\n    public int findPairs(int[] nums, int k) {\n        if (k < 0) return 0;\n        Set<Integer> numbers = new HashSet<>();\n        Set<Integer> found = new HashSet<>();\n        for (int n : nums) {\n            if (numbers.contains(n + k)) found.add(n);\n            if (numbers.contains(n - k)) found.add(n - k);\n            numbers.add(n);\n        }\n        return found.size();\n    }\n}\n```
[]