Page 1 of 1

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
by answerhappygod
Problem 5 12 Pts List Of Pairs Of Elements With Given Difference In A Sorted List Write A Function Which Receives As 1
Problem 5 12 Pts List Of Pairs Of Elements With Given Difference In A Sorted List Write A Function Which Receives As 1 (39.19 KiB) Viewed 31 times
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)]