β back to unit
Medium
# searching medium
The Most Expensive Item You Can Afford
You saved up allowance and you're going to spend it WISELY: the fanciest thing your money can buy. π°
You get a list of prices and your budget. Print the highest price that is still at most your budget, or keep saving if everything costs too much.
Example:
Input: prices = [45, 80, 30, 62], budget = 70
Output: 62
80 costs more than the budget, so it's disqualified. Among the rest (45, 30, 62), the highest is 62.
π‘ need a hint?
srch-best-affordable.pyπ given lines are locked β write your code in between
loading...