当前位置:网站首页>[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
边栏推荐
- [FreeRTOS interrupt experiment]
- Request (request object) and response (response object)
- 集合详解之 Collection + 面试题
- Distributed transaction solution
- [buuctf.reverse] 159_[watevrCTF 2019]Watshell
- Redis 排查大 key 的4种方法,优化必备
- Drive development - the first helloddk
- 内核判断i2c地址上是否挂载外设
- Postman test report
- Yolov5 tensorrt acceleration
猜你喜欢
What are the advantages of the industry private network over the public network? What specific requirements can be met?
Compilation and connection of shader in games202 webgl (learn from)
趋势前沿 | 达摩院语音 AI 最新技术大全
IPv6 comprehensive experiment
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
浅谈镜头滤镜的类型及作用
Microblogging hot search stock selection strategy
Embedded development program framework
Postman前置脚本-全局变量和环境变量
Principle and performance analysis of lepton lossless compression
随机推荐
EditorUtility.SetDirty在Untiy中的作用以及应用
Introduction of several RS485 isolated communication schemes
Postman断言
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
yolov5 tensorrt加速
Codeforces Round #804 (Div. 2)
项目经理,你会画原型嘛?项目经理需要做产品设计了?
Idea one key guide package
[FreeRTOS interrupt experiment]
Postman test report
Postman前置脚本-全局变量和环境变量
The kernel determines whether peripherals are attached to the I2C address
Mysql高级篇学习总结9:创建索引、删除索引、降序索引、隐藏索引
The web project imported the MySQL driver jar package but failed to load it into the driver
CUDA11.1在线安装
Acwing week 58
ISP learning (2)
Supreme Court, judgment standard of divorce cases
Ora-01779: the column corresponding to the non key value saving table cannot be modified
February 12 relativelayout