Your question is Count Less Than Using Binary Search. 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.
The Expedia app stores available hotel prices in a sorted integer array. Given the sorted prices and a target price, return how many prices are strictly less than the target.
You must solve the problem using binary search. Duplicate prices should be counted separately, and a price equal to the target is not considered less.
Implement count_less_than(prices, target).
prices, a nondecreasing list of integers, and target, an integer.prices whose value is strictly less than target.def count_less_than(prices, target):