当前位置:网站首页>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;
}
}
边栏推荐
- 如何给Arduino项目添加音乐播放功能
- Types de variables JS et transformations de type communes
- 编译原理:源程序的预处理及词法分析程序的设计与实现(含代码)
- 1041 Be Unique (20 point(s))(哈希:找第一个出现一次的数)
- (四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
- Fashion Gen: the general fashion dataset and challenge paper interpretation & dataset introduction
- idea中导包方法
- Mysqldump error1066 error solution
- 2021.11.10汇编考试
- JS variable types and common type conversions
猜你喜欢
Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
Générateur d'identification distribué basé sur redis
Walk into WPF's drawing Bing Dwen Dwen
Basic operations of databases and tables ----- creating data tables
Arduino uno R3 register writing method (1) -- pin level state change
ES6语法总结--上篇(基础篇)
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
Common properties of location
随机推荐
js 变量作用域和函数的学习笔记
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
SVN更新后不出现红色感叹号
[899]有序队列
Get the position of the nth occurrence of the string
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
Mysqldump error1066 error solution
基於Redis的分布式ID生成器
Arduino get random number
Who says that PT online schema change does not lock the table, or deadlock
2021.11.10汇编考试
Basic operations of databases and tables ----- modifying data tables
基于Redis的分布式ID生成器
Minio文件下载问题——inputstream:closed
(五)R语言入门生物信息学——ORF和序列分析
单片机蓝牙无线烧录
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
idea中导包方法
Pytorch: tensor operation (I) contiguous
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)