Fastest and Easiest Solution
\n# Approach\nInitialization:\n\nseen = {} (an empty HashSet to keep track of numbers we\'ve seen so far)\nuniquePairs = {} (an empty HashSet to store the first
\n# Approach\nInitialization:\n\nseen = {} (an empty HashSet to keep track of numbers we\'ve seen so far)\nuniquePairs = {} (an empty HashSet to store the first element of each unique pair)\n\n**Iteration 1:**\n\nCurrent number: 3\n\n    Check if 3 - 2 = 1 is in seen: false\n    Check if 3 + 2 = 5 is in seen: false\n    Add 3 to seen: seen = {3}\n\n**Iteration 2:**\n\nCurrent number: 1\n\n    Check if 1 - 2 = -1 is in seen: false\n    Check if 1 + 2 = 3 is in seen: true\n    Add 1 to uniquePairs: uniquePairs = {1}\n    Add 1 to seen: seen = {1, 3}\n\n**Iteration 3:**\n\nCurrent number: 4\n\n    Check if 4 - 2 = 2 is in seen: false\n    Check if 4 + 2 = 6 is in seen: false\n    Add 4 to seen: seen = {1, 3, 4}\n\n**Iteration 4:**\n\nCurrent number: 1\n\n    Check if 1 - 2 = -1 is in seen: false\n    Check if 1 + 2 = 3 is in seen: true\n    1 is already in uniquePairs, so no change.\n    Add 1 to seen: seen = {1, 3, 4} (no change as 1 is already present)\n\n\n**Iteration 5:**\n\nCurrent number: 5\n\n    Check if 5 - 2 = 3 is in seen: true\n    Add 3 to uniquePairs: uniquePairs = {1, 3}\n    Check if 5 + 2 = 7 is in seen: false\n    Add 5 to seen: seen = {1, 3, 4, 5}\n\n**Final Step:**\n\nThe size of uniquePairs is 2.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public int findPairs(int[] nums, int k) {\n        \n        if (k < 0) {\n            return 0;  // Since k is the absolute difference, it can\'t be negative\n        }\n\n        HashSet<Integer> seen = new HashSet<>();\n        HashSet<Integer> uniquePairs = new HashSet<>();\n\n        for (int num : nums) {\n            if (seen.contains(num - k)) {\n                uniquePairs.add(num - k);\n            }\n            if (seen.contains(num + k)) {\n                uniquePairs.add(num);\n            }\n            seen.add(num);\n        }\n\n        return uniquePairs.size();\n    }\n}\n```
['Java']