当前位置:网站首页>[leetcode daily question] number of enclaves
[leetcode daily question] number of enclaves
2022-07-06 05:02:00 【Oysters bring the sea to Chicago】
The number of enclaves
difficulty : Simple 
It can be used int The array records the number of occurrences of each character , Cyclic subtraction balloon The number of occurrences of each character , When it is not enough to reduce , Out of the loop .
The code is as follows :
public int maxNumberOfBalloons(String text) {
char[] chars = text.toCharArray();
int[] tmp = new int[128];
for (char aChar : chars) {
tmp[aChar]++;
}
int res = 0;
while(tmp['a']>=1&&tmp['b']>=1&&tmp['a']>=1&&tmp['l']>=2&&tmp['o']>=2&&tmp['n']>=1){
res++;
tmp['b']--;
tmp['a']--;
tmp['l']--;
tmp['l']--;
tmp['o']--;
tmp['o']--;
tmp['n']--;
}
return res;
}
Execution results : success 
边栏推荐
- Uva1592 Database
- 2021RoboCom机器人开发者大赛(初赛)
- Selection sort
- Postman manage test cases
- L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
- Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
- Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
- Ora-01779: the column corresponding to the non key value saving table cannot be modified
- Principle and performance analysis of lepton lossless compression
- TCP three handshakes you need to know
猜你喜欢

Principle and performance analysis of lepton lossless compression

GAMES202-WebGL中shader的编译和连接(了解向)

Introduction of several RS485 isolated communication schemes

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

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

A blog to achieve embedded entry

Ora-01779: the column corresponding to the non key value saving table cannot be modified

JS quick start (II)

DMA use of stm32
![[classic example] binary tree recursive structure classic topic collection @ binary tree](/img/39/0319c4be43716f927b9d98d89f7655.jpg)
[classic example] binary tree recursive structure classic topic collection @ binary tree
随机推荐
Biscuits (examination version)
Summary of redis basic knowledge points
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
TCP three handshakes you need to know
团队协作出了问题,项目经理怎么办?
Extension of graph theory
Uva1592 Database
The underlying structure of five data types in redis
F12 solve the problem that web pages cannot be copied
Quick sort
Postman前置脚本-全局变量和环境变量
Lepton 无损压缩原理及性能分析
Set detailed map + interview questions
MySQL time processing
RTP GB28181 文件测试工具
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
Bubble sort
Vite configures the development environment and production environment
RTP gb28181 document testing tool
2021RoboCom机器人开发者大赛(初赛)