Problem 2563 · Medium

Count the Number of Fair Pairs

Sort the numbers and count pairs with sum at most upper, subtract those with sum at most lower minus one, using two pointers.

Open the interactive visualisation