Fair Pairs
Mediumgreedysortingtwo pointers
Matchmaking may pair two players only if their ratings differ by at most k. Each player can be in at most one pair.
Return the largest number of pairs that can be formed.
Examples
Input: ratings = [1200,1500,1250,1490], k = 50
Output: 2
Input: ratings = [1000,2000], k = 100
Output: 0