C++ solution using set and hashmap. TC - O(nlogn) and SC - O(n)
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int,int> mp;\n        \n        int s = nums.size();\n        
```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int,int> mp;\n        \n        int s = nums.size();\n        \n        for(int i=0;i<s;i++)\n            mp[nums[i]] = i;\n        \n      \n        int res = 0;\n        \n        set<pair<int,int>> st;\n        \n        for(int i=0;i<s;i++) {\n            int d = nums[i]-k;\n            \n            if(mp.find(d)!=mp.end()  && i!=mp[d])\n                st.insert({nums[i],d});\n                \n        }\n        \n        return st.size();\n    }\n};\n```
['C', 'Ordered Set']