1189
给你一个字符串 text
,你需要使用 text
中的字母来拼凑尽可能多的单词 "balloon"(气球)。
字符串 text
中的每个字母最多只能被使用一次。请你返回最多可以拼凑出多少个单词 "balloon"。
示例 1:
输入:text = "nlaebolko" 输出:1
示例 2:
输入:text = "loonbalxballpoon" 输出:2
class Solution(object): def maxNumberOfBalloons(self, text): """ :type text: str :rtype: int """ return min(text.count('b'),text.count('a'),text.count('l')/2,text.count('o')/2,text.count('n'))
Work Hard
But do not forget to enjoy life😀
本文来自博客园,作者:YuhangLiuCE,转载请注明原文链接:https://www.cnblogs.com/YuhangLiuCE/p/17774245.html
posted on 2023-10-19 10:56 YuhangLiuCE 阅读(29) 评论(0) 收藏 举报