Your question is Smallest Number Above Lower Bound. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Airbnb search results may contain nightly prices sorted in nondecreasing order. Given a sorted list of prices and a lower bound, find the smallest price that is strictly greater than that bound.
Return -1 if no price satisfies the requirement.
Implement find_smallest_greater(prices, lower_bound).
prices is a sorted list of integers in nondecreasing order.lower_bound is an integer threshold.prices such that price > lower_bound.lower_bound, return -1.Because the list is sorted, use binary search rather than scanning every price.
def find_smallest_greater(prices, lower_bound):