You are viewing a single comment's thread. Return to all comments →
def maximumToys(prices, k): # Sort prices in ascending order prices.sort() # Initialize variables num_toys = 0 remaining_budget = k # Iterate through sorted prices for price in prices: if remaining_budget >= price: remaining_budget -= price num_toys += 1 else: break return num_toys
Seems like cookies are disabled on this browser, please enable them to open this website
Mark and Toys
You are viewing a single comment's thread. Return to all comments →