Find two orders with a given size difference
You have an unsorted list of order sizes and a positive threshold d. You want two orders whose sizes differ by exactly d.
sizes = [1, 5, 3, 4, 2], d = 3
-> (0, 3) # sizes[3] - sizes[0] == 4 - 1 == 3
Return the indices of any two distinct entries whose difference is d, or None. Aim for .
Show a hint
Two-sum asks "have I seen target - x?" A difference of d means one of two known values must already have appeared. Which two?
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.