100% faster || 8 ms || without using map || Worst Case O(n logn) + O(n)
\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        sort(nums.begin(), nums.end());\n        int slow = 0, fast = 1, ans = 0;\n 
```\nclass Solution {\npublic:\n    int findPairs(vector<int>& nums, int k) {\n        sort(nums.begin(), nums.end());\n        int slow = 0, fast = 1, ans = 0;\n        while(slow < nums.size() && fast < nums.size()){\n            if(nums[fast] - nums[slow] == k){\n                slow++;\n                fast++;\n                ans++;\n                while(fast < nums.size() && nums[fast] == nums[fast - 1]) fast++;\n            }\n            else if(nums[fast] - nums[slow] > k){\n                slow++;\n                if(fast - slow == 0) fast++;\n            }\n            else fast++;            \n        }\n        return ans;\n    }\n};\n```
['C', 'Sorting', 'C++']