- Problem
1833. Maximum Ice Cream Bars
- 내 풀이 (sort)
class Solution:
def maxIceCream(self, costs: List[int], coins: int) -> int:
costs.sort()
answer = 0
for cost in costs:
if coins >= cost:
answer += 1
coins -= cost
else:
break
return answer
- 결과
- 시간 복잡도:
O(NlogN)
- 공간 복잡도:
O(1)