C++ O(n) soln
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        unordered_map<int,int> m;\n        int c=0;\n   
```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        unordered_map<int,int> m;\n        int c=0;\n        \n        if(k<0) return 0;\n        \n        for(int i=0;i<n;i++){\n            m[nums[i]]++;\n        }\n        \n        if(k==0){\n            for(auto x:m){\n                if(x.second>1){\n                    c++;\n                }\n            }\n            return c;\n        }\n        \n        for(auto x:m){\n            if(m.count(x.first-k)){\n                c++;\n            }\n            \n        }\n        return c;\n    }\n    \n};\n```
[]