[DAY22]Pairs
Solution: First, we have to sort the given array. And we only need to traverse through the array once to find all the pairs. We start from the first and second clement of the sorted input array. If the right index element minus left index element equals to k. The we find a pair and both index move forward one step. If the right index element minus the left index less than k. In this situation, there might be an greater value in the array that minus the left index element equals to k. So we move the right index one step forward. In contrast, if the right index element minus the left index greater than k. In this situation, there might be an greater value in the array that right index element minus it can produce value k. So we move the left index one step forward.