[LeetCode] 1833. Maximum Ice Cream Bars

hizzang·2021년 7월 12일
0
post-thumbnail

문제 링크

https://leetcode.com/problems/maximum-ice-cream-bars/

제출 코드

class Solution:
    def maxIceCream(self, costs: List[int], coins: int) -> int:
        costs.sort()
        count = 0
        for i in costs:
            if(coins - i >= 0):
                count += 1
                coins -= i
        return count

0개의 댓글