PROBLEM 5 (12 pts) - List of pairs of elements with given difference in a sorted list Write a function which receives as
Posted: Wed Apr 27, 2022 3:36 pm
PROBLEM 5 (12 pts) - List of pairs of elements with given difference in a sorted list Write a function which receives as input a sorted list (smallest to largest) and the value of the difference and returns a list of pairs of numbers whose difference is equal to the given value. Your solution should be as efficient as possible. def listOfPairsWithGivenDifference (some SortedList, difference): Example: listOfPairsWithGivenDifference ([2,5,24,32,45,54,75],30) listOfPairsWithGivenDifference ([2,5,24,32,45,54,62],30) --> [(2,32), (24,54), (45,75)] --> [(2,32),(24,54),(32,62)]