当前位置:网站首页>[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 
边栏推荐
- Rce code and Command Execution Vulnerability
- Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
- Postman测试报告
- ISP learning (2)
- Golang -- TCP implements concurrency (server and client)
- yolov5 tensorrt加速
- It is also a small summary in learning
- 2021robocom robot developer competition (Preliminary)
- [buuctf.reverse] 159_ [watevrCTF 2019]Watshell
- Collection + interview questions
猜你喜欢

Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago

DMA use of stm32

ORM aggregate query and native database operation

Basic knowledge and examples of binary tree

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

Compilation et connexion de shader dans games202 - webgl (comprendre la direction)

February 12 relativelayout

Principle and performance analysis of lepton lossless compression

Rce code and Command Execution Vulnerability

Postman断言
随机推荐
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
RTP GB28181 文件测试工具
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Postman管理测试用例
win10电脑系统里的视频不显示缩略图
Three. JS learning - light and shadow (understanding)
集合详解之 Collection + 面试题
EditorUtility.SetDirty在Untiy中的作用以及应用
關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
Some common skills on unity inspector are generally used for editor extension or others
What should the project manager do if there is something wrong with team collaboration?
[mathematical modeling] differential equation -- sustainable development of fishing industry
[NOIP2008 提高组] 笨小猴
Drive development - the first helloddk
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Summary of redis basic knowledge points
MySQL if and ifnull use
2021 robocom world robot developer competition - undergraduate group (semi-finals)
你需要知道的 TCP 三次握手
Basic knowledge and examples of binary tree