当前位置:网站首页>Daily question 1189 Maximum number of "balloons"

Daily question 1189 Maximum number of "balloons"

2022-07-05 06:12:00 A big pigeon

topic :

Give you a string text, You need to use text To piece together as many words as possible "balloon"( balloon ).

character string text Each letter in can only be used once at most . Please return the maximum number of words you can piece together "balloon".

Explain : Count , The number of words is determined by the minimum number of letters .( Barrel effect )

class Solution:
    def maxNumberOfBalloons(self, text: str) -> int:
        cnt = Counter(text)
        return min(cnt["b"],cnt["a"],cnt["l"]//2,cnt["o"]//2,cnt["n"])

原网站

版权声明
本文为[A big pigeon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140620422142.html