C++| Two pointers | Lower Bound | nlogn
Using two pointer C++ | nlogn :\n\nint findPairs(vector<int>& nums, int k) {\n        int ans=0;\n        sort(nums.begin(),nums.end());\n        int i=0,j=1;\n
### Using two pointer C++ | nlogn :\n```\nint findPairs(vector<int>& nums, int k) {\n        int ans=0;\n        sort(nums.begin(),nums.end());\n        int i=0,j=1;\n        int n=nums.size();\n        while(i<n &&j<n){                                      \n            if(i!=0 && nums[i]==nums[i-1]){i++;continue;}\n            if(i==j) {j++;continue;}\n            \n            int dif=nums[j]-nums[i];\n            if(dif==k){i++;ans++;}\n            else if(dif<k) j++;\n            else i++;\n        }\n      return ans;\n}\n```\n\n### Using Lower Bound C++ | nlogn :\n```\nint findPairs(vector<int>& nums, int k) {\n        int ans=0;\n        sort(nums.begin(),nums.end());\n        for(auto it=nums.begin();it!=nums.end();it++){         \n            if(it!=nums.begin() && *it==*(it-1)) continue; \n            auto itr=lower_bound(it+1,nums.end(),k+(*it));\n            if(itr==nums.end()) continue;\n            if(*itr-*it==k){\n                ans++;\n            }\n        }\n         return ans;\n  }\n```
['C']