C++ super-simple solution O(n), faster than 100%
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int, int> map;\n        for(auto num:nums)\n            map[nu
```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        unordered_map<int, int> map;\n        for(auto num:nums)\n            map[num]++;\n        \n        int res = 0;\n        if (k > 0) {\n            for(auto a:map)\n                if (map.find(a.first+k) != map.end()) \n                    res++;\n        }\n        \n        else {\n            for(auto a:map)\n                if (a.second > 1)\n                    res++;\n        }\n        \n        return res;\n    }\n};\n```\n**Like it? please upvote...**
['C']