当前位置:网站首页>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();
}
边栏推荐
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- 树莓派3.5寸屏幕白屏显示连接
- ORM aggregate query and native database operation
- win10电脑系统里的视频不显示缩略图
- Three methods of Oracle two table Association update
- Huawei equipment is configured with OSPF and BFD linkage
- Fuzzy -- basic application method of AFL
- 团队协作出了问题,项目经理怎么办?
- [NOIP2009 普及组] 分数线划定
- [NOIP2008 提高组] 笨小猴
猜你喜欢
Programmers' position in the Internet industry | daily anecdotes
Imperial cms7.5 imitation "D9 download station" software application download website source code
F12 solve the problem that web pages cannot be copied
ByteDance program yuan teaches you how to brush algorithm questions: I'm not afraid of the interviewer tearing the code
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Fuzzy -- basic application method of AFL
RT thread analysis log system RT_ Kprintf analysis
RTP gb28181 document testing tool
二叉树基本知识和例题
Weng Kai C language third week 3.1 punch in
随机推荐
图论的扩展
趋势前沿 | 达摩院语音 AI 最新技术大全
树莓派3.5寸屏幕白屏显示连接
GAMES202-WebGL中shader的编译和连接(了解向)
Upload nestjs configuration files, configure the use of middleware and pipelines
ISP学习(2)
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Mongodb basic knowledge summary
ISP learning (2)
Class inheritance in yyds dry inventory C
Golang -- TCP implements concurrency (server and client)
Oracle query table index, unique constraint, field
nacos-高可用seata之TC搭建(02)
关于imx8mp的es8316的芯片调试
Pagoda configuration mongodb
ByteDance program yuan teaches you how to brush algorithm questions: I'm not afraid of the interviewer tearing the code
Request (request object) and response (response object)
EditorUtility. The role and application of setdirty in untiy
What are the advantages of the industry private network over the public network? What specific requirements can be met?
你需要知道的 TCP 三次握手