当前位置:网站首页>Force buckle 1189 Maximum number of "balloons"
Force buckle 1189 Maximum number of "balloons"
2022-07-06 05:06:00 【Three watch ghost】
Title source :https://leetcode-cn.com/problems/maximum-number-of-balloons/
General meaning :
Give a string , Find out how many words the letters can form balloon
Ideas
- Traversal string , Statistics balloon Number of corresponding letters
- Returns the least number of letters in the statistics
public int maxNumberOfBalloons(String text) {
int[] count = new int[5];
int n = text.length();
for (int i = 0; i < n; i++) {
char c = text.charAt(i);
switch (c) {
case 'b':
count[0]++;
break;
case 'a':
count[1]++;
break;
case 'l':
count[2]++;
break;
case 'o':
count[3]++;
break;
case 'n':
count[4]++;
break;
default:
break;
}
}
count[2] /= 2;
count[3] /= 2;
return Arrays.stream(count).min().getAsInt();
}
边栏推荐
- Imperial cms7.5 imitation "D9 download station" software application download website source code
- JS quick start (II)
- Flink kakfa data read and write to Hudi
- Mongodb basic knowledge summary
- 图数据库ONgDB Release v-1.0.3
- MySQL time processing
- The underlying structure of five data types in redis
- 2021robocom robot developer competition (Preliminary)
- 麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
- Nacos - TC Construction of High available seata (02)
猜你喜欢
Class inheritance in yyds dry inventory C
用StopWatch 统计代码耗时
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
Nacos TC setup of highly available Seata (02)
Compilation and connection of shader in games202 webgl (learn from)
acwing周赛58
你需要知道的 TCP 三次握手
Fuzzy -- basic application method of AFL
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
随机推荐
JS quick start (II)
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
IPv6 comprehensive experiment
The kernel determines whether peripherals are attached to the I2C address
Excellent PM must experience these three levels of transformation!
2021 robocom world robot developer competition - undergraduate group (semi-finals)
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
[lgr-109] Luogu may race II & windy round 6
Postman前置脚本-全局变量和环境变量
Please wait while Jenkins is getting ready to work
Redis 排查大 key 的4种方法,优化必备
Postman管理测试用例
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
Orm-f & Q object
Postman Association
win10电脑系统里的视频不显示缩略图
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
二叉树基本知识和例题
【LGR-109】洛谷 5 月月赛 II & Windy Round 6