当前位置:网站首页>1189. Maximum number of "balloons"
1189. Maximum number of "balloons"
2022-07-04 01:38:00 【@[toc] (directory)】
https://leetcode-cn.com/problems/maximum-number-of-balloons/

This question , Adopt statistical method ,
Barrel effect , A bucket can hold water , It depends on the shortest board
class Solution {
public int maxNumberOfBalloons(String text) {
int[] cnts = new int[5];
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c == 'b') cnts[0]++;
else if (c == 'a') cnts[1]++;
else if (c == 'l') cnts[2]++;
else if (c == 'o') cnts[3]++;
else if (c == 'n') cnts[4]++;
}
cnts[2] /= 2; cnts[3] /= 2;
int ans = cnts[0];
// Be careful min Usage of
for (int i = 0; i < 5; i++) ans = Math.min(ans, cnts[i]);
return ans;
}
}
边栏推荐
- [turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
- How to use AHAS to ensure the stability of Web services?
- 查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
- Huawei cloud micro certification Huawei cloud computing service practice has been stable
- Magical usage of edge browser (highly recommended by program ape and student party)
- Remember a lazy query error
- When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
- Flex flexible layout, box in the middle of the page
- Fundamentals of machine learning: feature selection with lasso
- MySQL deadly serial question 2 -- are you familiar with MySQL index?
猜你喜欢

Maximum entropy model

Some other configurations on Huawei's spanning tree

How to delete MySQL components using xshell7?

MySQL deadly serial question 2 -- are you familiar with MySQL index?

LeetCode226. Flip binary tree

LeetCode 168. Detailed explanation of Excel list name
![Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading](/img/d2/99932660298b4a4cddd7e5e69faca1.png)
Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading

Feign implements dynamic URL

技术实践|线上故障分析及解决方法(上)

Force buckle day32
随机推荐
Summary of common tools and technical points of PMP examination
QML add gradient animation during state transition
Ceramic metal crowns - current market situation and future development trend
Special copy UML notes
Day05 table
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
PMP 考试常见工具与技术点总结
Remember a lazy query error
Luogu p1309 Swiss wheel
be based on. NETCORE development blog project starblog - (14) realize theme switching function
Future source code view -juc series
Make drop-down menu
Jerry's watch information type table [chapter]
LeetCode226. Flip binary tree
Stringutils and collectionutils
Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Technical practice online fault analysis and solutions (Part 1)
Introduction to superresolution