leetcode 1833

Posted 东东就是我

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 1833相关的知识,希望对你有一定的参考价值。

class Solution:
    def maxIceCream(self, costs: List[int], coins: int) -> int:
        if coins<min(costs):
            return 0
        if coins>sum(costs):
            return len(costs)
        coin=0
        costs.sort()
        for i,cost in enumerate(costs):
            coin+=cost
            if coin>coins:
                return i
                break
            if coin==coins:
                return i+1
                break

以上是关于leetcode 1833的主要内容,如果未能解决你的问题,请参考以下文章