close
題目:
Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible.
You can use each character in text at most once. Return the maximum number of instances that can be formed.
簡易版本:
檢視輸入字串可以形成幾個完整ballon
解題想法:
檢視ballon字數,l除二取最小即可
code:
class Solution: def maxNumberOfBalloons(self, text: str) -> int: return min(text.count("b"),text.count("a"),text.count("l")//2,text.count("o")//2,text.count("n"))
文章標籤
全站熱搜
留言列表