Easy C++ Soln || nlogn || One pointer with Binary Search
\nclass Solution {\npublic:\n    //one pointer with binary search nlogn\n    int findPairs(vector<int>& nums, int k) {\n        int ans=0;\n        sort(nums.be
```\nclass Solution {\npublic:\n    //one pointer with binary search nlogn\n    int findPairs(vector<int>& nums, int k) {\n        int ans=0;\n        sort(nums.begin(),nums.end());\n        for(int i=0;i<nums.size()-1;i++){\n            if(i>0 && nums[i]==nums[i-1])continue;\n            int x=nums[i];\n            int l=i+1,r=nums.size()-1;\n            while(l<=r){\n                int m=(l+r)>>1;\n                if(nums[m]-x==k){\n                    ans++;\n                    break;\n                }\n                else if(nums[m]-x>k)r=m-1;\n                else l=m+1;\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'Binary Tree']