C++ || Simple easy solution || Two pointer technique
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n       int count
```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n       int count=0;\n        int i=0;\n        int j=1;\n        while(i<n && j<n)\n        {\n            if(i!=j && nums[j]-nums[i]==k){\n                while(i+1 < n && nums[i+1] == nums[i]) // to check for distinct pairs\n                    i++;\n                i++;\n                while(j+1<n && nums[j+1] == nums[j]) //to check for distinct pairs\n                    j++;\n                j++;\n                count++;\n            }\n            else if(nums[j]-nums[i]<k) j++;\n            else i++;\n        }\n        return count;\n    }\n};\n```\n
['Two Pointers', 'C']