Java 6ms, Beats 98% Simple 2-Pointer Approach
This is a pretty standard 2 pointer approach with a unique take away when looking at duplicates. One thing that took me a little bit to wrap my head around was 
This is a pretty standard 2 pointer approach with a unique take away when looking at duplicates. One thing that took me a little bit to wrap my head around was how we can accurately determine what is a valid answer. I also didn\'t see any posts where they showed this approach so I thought I would share.\n\n\nTo start I think its easier to look at, what IS NOT a valid answer.\n1. If the left pointer has caught up to our right pointer. This is between two different values so if left == right, this will never be a valid answer.\n2. If we have previously used this value to accurately determine that two values compute a valid answer.\n\t* \tFor this problem I used a previous variable and set it whenever we find a value where nums[r] - nums[l] == k. This stops any sort of duplicates from happening.\n3. As mentioned earlier we must also check that nums[r]-nums[l] == k. We use the while loop to get as close as possible for each iteration but we need the final if statement to check accuracy.\n\nHope this helps someone!\n```\nclass Solution {\n    public int findPairs(int[] nums, int k) {\n        if(nums == null || nums.length < 1) return 0;\n        \n        Arrays.sort(nums);\n        int l = 0, ans = 0, prev = Integer.MAX_VALUE;\n        for(int r = 1; r < nums.length; r++) {\n            while(l < r && nums[r] - nums[l] > k) l++;\n            \n            if(l != r && prev != nums[l] && nums[r] - nums[l] == k) {\n                ans++;\n                prev = nums[l];\n            }\n        }\n        return ans;\n    }\n}\n```
['Two Pointers', 'Java']