An eBay checkout flow needs to identify two listings whose prices exactly match a customer’s budget. Given an array of integer listing prices and a target budget, return the lexicographically smallest pair of distinct indices whose prices sum to the target.
A pair [i, j] must satisfy i < j and prices[i] + prices[j] == budget. Pair [a, b] is lexicographically smaller than [c, d] when a < c, or when a == c and b < d. Return [-1, -1] if no valid pair exists.
Implement find_listing_pair(prices, budget).
prices, a list of integers, and budget, an integer.[-1, -1] when no pair exists.def find_listing_pair(prices, budget):