HackerRank: Mark and Toys
Tags: hackerrank, 紮馬步
Mark and Toys
- python
# Complete the maximumToys function below.
def maximumToys(prices, k):
max_unit = 0
prices.sort()
for i_price in prices:
k = k - i_price
if k >= 0:
max_unit += 1
else:
break
return max_unit