Skip to content

Commit

Permalink
Create max-ice-cream.py
Browse files Browse the repository at this point in the history
maximum icecream that can be bought
  • Loading branch information
gabedonnan authored Jan 12, 2023
1 parent 25daafb commit 156ab64
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions max-ice-cream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution(object):
def maxIceCream(self, costs, coins):
"""
:type costs: List[int]
:type coins: int
:rtype: int
"""
costs = sorted(costs)
count = 0
for c in costs:
if c <= coins:
coins -= c
count += 1
else:
return count
return count

0 comments on commit 156ab64

Please sign in to comment.