当前位置:网站首页>Force buckle 1189 Maximum number of "balloons"
Force buckle 1189 Maximum number of "balloons"
2022-07-06 12:29:00 【Yangshiwei....】
subject :
analysis :
First of all, you should count all the times of the relevant letters of the balloon word , Then we found that in this word ,l and o It appears twice , The others only appeared once , So we divide them 2 Rounding down , Then find out the minimum value of five words .
Code :
class Solution {
public int maxNumberOfBalloons(String text) {
int [] a=new int[5];
for(int i=0;i<text.length();i++){
char c=text.charAt(i);
if(c=='b'){
a[0]++;
}
if(c=='a'){
a[1]++;
}
if(c=='l'){
a[2]++;
}
if(c=='o'){
a[3]++;
}
if(c=='n'){
a[4]++;
}
}
a[2]/=2;
a[3]/=2;
return min(a[0],a[1],a[2],a[3],a[4]);
}
public int min(int a,int b,int c,int d,int e){
if(a>b){
a=b;
}
if(a>c){
a=c;
}
if(a>d){
a=d;
}
if(a>e){
a=e;
}
return a;
}
}
边栏推荐
- [Nodejs] 20. Koa2 onion ring model ----- code demonstration
- Esp8266 connect onenet (old mqtt mode)
- [leetcode19] delete the penultimate node in the linked list
- Pat 1097 duplication on a linked list (25 points)
- Knowledge summary of request
- Embedded startup process
- Unity3D摄像机,键盘控制前后左右上下移动,鼠标控制旋转、放缩
- [899] ordered queue
- Basic operations of databases and tables ----- view data tables
- Redis based distributed ID generator
猜你喜欢
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
程序设计大作业:教务管理系统(C语言)
JS数组常用方法的分类、理解和运用
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
Programmers can make mistakes. Basic pointers and arrays of C language
ES6语法总结--下篇(进阶篇 ES6~ES11)
open-mmlab labelImg mmdetection
2021.11.10汇编考试
ES6 grammar summary -- Part I (basic)
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
随机推荐
[offer9] implement queues with two stacks
关于Gateway中使用@Controller的问题
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
嵌入式启动流程
Redis based distributed locks and ultra detailed improvement ideas
Whistle+switchyomega configure web proxy
@The difference between Autowired and @resource
1041 Be Unique (20 point(s))(哈希:找第一个出现一次的数)
Knowledge summary of request
Basic operations of databases and tables ----- classification of data
History object
Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
(五)R语言入门生物信息学——ORF和序列分析
Imgcat usage experience
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
Types de variables JS et transformations de type communes
Flink late data processing (3)
Esp8266 connects to onenet cloud platform (mqtt) through Arduino IDE
ESP8266连接onenet(旧版MQTT方式)
@Autowired 和 @Resource 的区别