当前位置:网站首页>LeetCode:1189. The maximum number of "balloons" -- simple
LeetCode:1189. The maximum number of "balloons" -- simple
2022-07-06 21:44:00 【Kinght_ one hundred and twenty-three】
subject
1189. “ balloon ” Maximum number of
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”.
Example 1:
Input :text = “nlaebolko”
Output :1
Example 2:

Input :text = “loonbalxballpoon”
Output :2
Example 3:
Input :text = “leetcode”
Output :0
Tips :
- 1 <= text.length <= 10^4
- text All consist of lowercase English letters
Their thinking
- Statistics .
- One balloon By a b, One a, Two l, Two o, One n.
- So we need to take l and o Number of divided by 2, Then make statistics .
Code
class Solution:
def maxNumberOfBalloons(self, text: str) -> int:
dic = Counter(ch for ch in text if ch in "balloon")
dic['o'] //= 2
dic['l'] //= 2
return min(dic.values()) if len(dic) == 5 else 0
Running results

边栏推荐
- El table table - sortable sorting & disordered sorting when decimal and% appear
- 代理和反向代理
- PostgreSQL modifies the password of the database user
- From campus to Tencent work for a year of those stumbles!
- JS learning notes OO create suspicious objects
- 首批入选!腾讯安全天御风控获信通院业务安全能力认证
- 14年本科毕业,转行软件测试,薪资13.5K
- Set up a time server
- 50个常用的Numpy函数解释,参数和使用示例
- 启动嵌入式间:资源有限的系统启动
猜你喜欢

Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
![[in depth learning] pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs](/img/66/4d94ae24e99599891636013ed734c5.png)
[in depth learning] pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs

数字化转型挂帅复产复工,线上线下全融合重建商业逻辑

缓存更新策略概览(Caching Strategies Overview)

Yuan Xiaolin: safety is not only a standard, but also Volvo's unchanging belief and pursuit

【滑动窗口】第九届蓝桥杯省赛B组:日志统计

Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic

C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events

美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断

numpy 下载安装
随机推荐
麦趣尔砸了小众奶招牌
Summary of cross partition scheme
Absolute primes (C language)
Explain ESM module and commonjs module in simple terms
Fzu 1686 dragon mystery repeated coverage
From campus to Tencent work for a year of those stumbles!
038. (2.7) less anxiety
What about the spectrogram
一行代码可以做些什么?
快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
基于InsightFace的高精度人脸识别,可直接对标虹软
Uni app app half screen continuous code scanning
Redistemplate common collection instructions opsforhash (IV)
guava:Collections.unmodifiableXXX创建的collection并不immutable
Yyds dry inventory run kubeedge official example_ Counter demo counter
JS learning notes OO create suspicious objects
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
ACdreamoj1110(多重背包)
[go][转载]vscode配置完go跑个helloworld例子
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地