c++ using map easy soln
\nclass Solution {\npublic:\n    int findPairs(vector& nums, int k) {\n       \n        int n = nums.size();\n        mapm;        \n        for(int i = 0;i1){\
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n       \n        int n = nums.size();\n        map<int,int>m;        \n        for(int i = 0;i<n;i++)\n        {\n            m[nums[i]]++;\n        }\n        int sum = 0; \n        if(k == 0){\n            for(auto i:m){\n                if(i.second>1){\n                    sum++;\n                }\n            }\n        }\n        else{\n            for(auto i:m){\n                if( m.count(i.first + k))\n               //if(m.find(i.first + k)!=m.end()) \n                {\n                    sum++;\n                }\n            }\n        }\n        return sum;\n       \n    }\n};
[]