当前位置:网站首页>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();
}
边栏推荐
- Tetris
- Fuzzy -- basic application method of AFL
- Review of double pointer problems
- Postman前置脚本-全局变量和环境变量
- Summary of redis AOF and RDB knowledge points
- 二叉树基本知识和例题
- 麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
- Project manager, can you draw prototypes? Does the project manager need to do product design?
- L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
- 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
猜你喜欢

Weng Kai C language third week 3.1 punch in

ISP学习(2)

你需要知道的 TCP 三次握手

JS quick start (II)

Postman管理测试用例
![[lgr-109] Luogu may race II & windy round 6](/img/fe/d5b67c7dff759c519a04da023630ea.png)
[lgr-109] Luogu may race II & windy round 6

flutter 实现一个有加载动画的按钮(loadingButton)

What are the advantages of the industry private network over the public network? What specific requirements can be met?

ISP learning (2)

A blog to achieve embedded entry
随机推荐
关于es8316的音频爆破音的解决
Idea one key guide package
Supreme Court, judgment standard of divorce cases
Drive development - the first helloddk
Summary of redis basic knowledge points
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Postman Association
内核判断i2c地址上是否挂载外设
ORM aggregate query and native database operation
A little knowledge of CPU, disk and memory
[NOIP2009 普及组] 分数线划定
On the solution of es8316's audio burst
TCP three handshakes you need to know
JS quick start (II)
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
组播和广播的知识点梳理
Tetris
關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
What are the advantages of the industry private network over the public network? What specific requirements can be met?
Collection + interview questions