当前位置:网站首页>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;
}
}边栏推荐
- Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0
- Mysqldump error1066 error solution
- VSCode基础配置
- 【ESP32学习-1】Arduino ESP32开发环境搭建
- Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
- Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
- 编译原理:源程序的预处理及词法分析程序的设计与实现(含代码)
- Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
- JS function promotion and declaration promotion of VaR variable
- Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
猜你喜欢

Types de variables JS et transformations de type communes

js 变量作用域和函数的学习笔记

Amba, ahb, APB, Axi Understanding

js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。

Vulnhub target: hacknos_ PLAYER V1.1

(4) Data visualization of R language -- matrix chart, histogram, pie chart, scatter chart, linear regression and strip chart

【ESP32学习-1】Arduino ESP32开发环境搭建

Unity3D制作注册登录界面,并实现场景跳转

MySQL占用内存过大解决方案
![[Red Treasure Book Notes simplified version] Chapter 12 BOM](/img/ff/0ad410b5b556c0e16a4076a2a0577b.jpg)
[Red Treasure Book Notes simplified version] Chapter 12 BOM
随机推荐
JS 函数提升和var变量的声明提升
Basic operations of databases and tables ----- modifying data tables
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
2022.2.12 resumption
[899]有序队列
SSD technical features
[Nodejs] 20. Koa2 onion ring model ----- code demonstration
[offer78]合并多个有序链表
Générateur d'identification distribué basé sur redis
Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
Cannot change version of project facet Dynamic Web Module to 2.3.
Use of lists
Basic operations of databases and tables ----- view data tables
(一)R语言入门指南——数据分析的第一步
[offer78] merge multiple ordered linked lists
(课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
基于Redis的分布式ID生成器
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
By v$rman_ backup_ job_ Oracle "bug" caused by details