当前位置:网站首页>[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
边栏推荐
- Ora-01779: the column corresponding to the non key value saving table cannot be modified
- Summary of three log knowledge points of MySQL
- What should the project manager do if there is something wrong with team collaboration?
- Oracle query table index, unique constraint, field
- Biscuits (examination version)
- 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
- nacos-高可用seata之TC搭建(02)
- [数学建模] 微分方程--捕鱼业的持续发展
- Postman test report
猜你喜欢
TCP three handshakes you need to know
Application of Flody
Orm-f & Q object
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
[FreeRTOS interrupt experiment]
A blog to achieve embedded entry
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
yolov5 tensorrt加速
RTP gb28181 document testing tool
GAMES202-WebGL中shader的編譯和連接(了解向)
随机推荐
[NOIP2009 普及组] 分数线划定
The kernel determines whether peripherals are attached to the I2C address
Redis 排查大 key 的4種方法,優化必備
Finance online homework
acwing周赛58
web工程导入了mysql驱动jar包却无法加载到驱动的问题
驱动开发——第一个HelloDDK
二叉树基本知识和例题
Idea one key guide package
GAMES202-WebGL中shader的編譯和連接(了解向)
Oracle query table index, unique constraint, field
Raspberry pie 3.5-inch white screen display connection
Fuzzy -- basic application method of AFL
ISP learning (2)
浅谈镜头滤镜的类型及作用
你需要知道的 TCP 三次握手
Redis 排查大 key 的4种方法,优化必备
MySQL if and ifnull use
Driver development - hellowdm driver
Collection + interview questions