当前位置:网站首页>[leectode 2022.2.13] maximum number of "balloons"
[leectode 2022.2.13] maximum number of "balloons"
2022-07-06 10:36:00 【Procedural ape does not lose hair 2】
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
java Code :
class Solution {
public int maxNumberOfBalloons(String text) {
int[] cnt = new int[5];
for (int i = 0; i < text.length(); ++i) {
char ch = text.charAt(i);
if (ch == 'b') {
cnt[0]++;
} else if (ch == 'a') {
cnt[1]++;
} else if (ch == 'l') {
cnt[2]++;
} else if (ch == 'o') {
cnt[3]++;
} else if (ch == 'n') {
cnt[4]++;
}
}
cnt[2] /= 2;
cnt[3] /= 2;
return Arrays.stream(cnt).min().getAsInt();
}
}
边栏推荐
- Transactions have four characteristics?
- How to build an interface automation testing framework?
- [after reading the series of must know] one of how to realize app automation without programming (preparation)
- 16 medical registration system_ [order by appointment]
- 第一篇博客
- MySQL27-索引優化與查詢優化
- Super detailed steps for pushing wechat official account H5 messages
- Google login prompt error code 12501
- Record the first JDBC
- Mysql27 - Optimisation des index et des requêtes
猜你喜欢
![[unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in](/img/1f/93a6c6150ec2b002f667a882569b7b.jpg)
[unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in

MySQL32-锁

MySQL底层的逻辑架构

MySQL combat optimization expert 02 in order to execute SQL statements, do you know what kind of architectural design MySQL uses?

MySQL33-多版本并发控制

MySQL23-存储引擎

Mysql27 - Optimisation des index et des requêtes

Mysql24 index data structure

MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位

Use xtrabackup for MySQL database physical backup
随机推荐
Introduction tutorial of typescript (dark horse programmer of station B)
Time complexity (see which sentence is executed the most times)
Mysql33 multi version concurrency control
Sichuan cloud education and double teacher model
Bytetrack: multi object tracking by associating every detection box paper reading notes ()
C miscellaneous two-way circular linked list
MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
Ueeditor internationalization configuration, supporting Chinese and English switching
Mysql35 master slave replication
A necessary soft skill for Software Test Engineers: structured thinking
MySQL实战优化高手02 为了执行SQL语句,你知道MySQL用了什么样的架构设计吗?
Windchill配置远程Oracle数据库连接
用于实时端到端文本识别的自适应Bezier曲线网络
13 medical registration system_ [wechat login]
Use xtrabackup for MySQL database physical backup
First blog
MySQL combat optimization expert 06 production experience: how does the production environment database of Internet companies conduct performance testing?
使用OVF Tool工具从Esxi 6.7中导出虚拟机
Google login prompt error code 12501
UEditor国际化配置,支持中英文切换