Swift   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了[Swift]LeetCode1189.大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ?微信公众号:为敢(WeiGanTechnologies) ?博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/) ?GitHub地址:https://github.com/strengthen/LeetCode ?原文地址:https://www.cnblogs.com/s

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
?微信公众号:为敢(WeiGanTechnologies)
?博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/
?GitHub地址:https://github.com/strengthen/LeetCode
?原文地址:https://www.cnblogs.com/strengthen/p/11521665.html
?如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章
?原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

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.

 

Example 1:

[Swift]LeetCode1189.

Input: text = "nlaebolko"
Output: 1

Example 2:

[Swift]LeetCode1189.

Input: text = "loonbalxballpoon"
Output: 2

Example 3:

Input: text = "leetcode"
Output: 0

 

Cons@R_262_9829@nts:

  • 1 <= text.length <= 10^4
  • text consists of lower case English letters only.

给你一个字符串 text,你需要使用 text 中的字母来拼凑尽可能多的单词 "balloon"(气球)。

字符串 text 中的每个字母最多只能被使用一次。请你返回最多可以拼凑出多少个单词 "balloon"。

 

示例 1:

[Swift]LeetCode1189.

输入:text = "nlaebolko"
输出:1

示例 2:

[Swift]LeetCode1189.

输入:text = "loonbalxballpoon"
输出:2

示例 3:

输入:text = "leetcode"
输出:0

 

提示

  • 1 <= text.length <= 10^4
  • text 全部由小写英文字母组成
Runtime: 16 ms
Memory Usage: 20.7 MB
 1 class Solution {
 2     func maxnumberOfBalloons(_ text: String) -> Int {
 3         var F:[Character:Int] = [Character:Int]()
 4         for c in text
 5         {
 6             F[c,default:0] += 1
 7         }
 8         return min(F["b",default:0],F["a",F["l",default:0]/2,F["o",F["n",default:0])
 9     }
10 }

大佬总结

以上是大佬教程为你收集整理的[Swift]LeetCode1189.全部内容,希望文章能够帮你解决[Swift]LeetCode1189.所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。