C++ Solution
Code\n\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int, int> mp;\n        for(int x: nums) mp[x]++;\n      
# Code\n```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int, int> mp;\n        for(int x: nums) mp[x]++;\n        int ans = 0;\n        for(auto x: mp) {\n            if (k == 0) {    \n                if(x.second > 1) ans++;\n            }\n            else if (mp.find(x.first + k) != mp.end()) ans++;\n        }\n        return ans;\n    }\n};\n```
['C++']