当前位置:网站首页>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;
}
}
边栏推荐
- Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
- C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
- Ceramic metal crowns - current market situation and future development trend
- File contains vulnerability summary
- AI 助力艺术设计抄袭检索新突破!刘芳教授团队论文被多媒体顶级会议ACM MM录用
- Related configuration commands of Huawei rip
- MPLS③
- Is Shengang securities company as safe as other securities companies
- MySQL - use of aggregate functions and group by groups
- Day05 branch and loop (II)
猜你喜欢
Gee: create a new feature and set corresponding attributes
Conditional statements of shell programming
Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Remember a lazy query error
Infiltration learning diary day19
Setting function of Jerry's watch management device [chapter]
长文综述:大脑中的熵、自由能、对称性和动力学
2020-12-02 SSM advanced integration Shang Silicon Valley
Thinkphp6 integrated JWT method and detailed explanation of generation, removal and destruction
随机推荐
MPLS③
Solution to the problem that jsp language cannot be recognized in idea
Conditional statements of shell programming
Jerry's modification setting status [chapter]
Openbionics exoskeleton project introduction | bciduino community finishing
Software product download collection
Oracle database knowledge points (IV)
Ceramic metal crowns - current market situation and future development trend
How to delete MySQL components using xshell7?
Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
Huawei cloud micro certification Huawei cloud computing service practice has been stable
TP5 automatic registration hook mechanism hook extension, with a complete case
Audio resource settings for U3D resource management
Three layer switching ②
Gnupg website
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
【.NET+MQTT】. Net6 environment to achieve mqtt communication, as well as bilateral message subscription and publishing code demonstration of server and client
Feign implements dynamic URL
Functions and arrays of shell scripts