当前位置:网站首页>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;
}
}
边栏推荐
- Conditional test, if, case conditional test statements of shell script
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- HackTheBox-baby breaking grad
- Feign implements dynamic URL
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
- C import Xls data method summary II (save the uploaded file to the DataTable instance object)
- 51 MCU external interrupt
- Special copy UML notes
- Solution to the problem that jsp language cannot be recognized in idea
- Conditional statements of shell programming
猜你喜欢

Thinkphp6 integrated JWT method and detailed explanation of generation, removal and destruction

How can enterprises optimize the best cost of cloud computing?

Audio resource settings for U3D resource management

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

Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?

TP5 automatic registration hook mechanism hook extension, with a complete case

Gee: create a new feature and set corresponding attributes

长文综述:大脑中的熵、自由能、对称性和动力学

IPv6 experiment

Do you know the eight signs of a team becoming agile?
随机推荐
C import Xls data method summary V (complete code)
Introduction to superresolution
Three layer switching ①
MySQL statement learning record
All metal crowns - current market situation and future development trend
Future source code view -juc series
Prose article appreciation - the rain in the warm country has never changed into cold, hard and brilliant flowers. Knowledgeable people think he is monotonous, and he thinks he is unlucky, doesn't he?
Mongodb learning notes: command line tools
MySQL -- Introduction and use of single line functions
Skku| autonomous handover decision of UAV Based on deep reinforcement learning
Summary of JWT related knowledge
Jerry's watch information type table [chapter]
Cancer biopsy instruments and kits - market status and future development trends
mysql使用视图报错,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
Douban scoring applet Part-3
Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading
All ceramic crowns - current market situation and future development trend
C import Xls data method summary III (processing data in datatable)
HackTheBox-baby breaking grad
About uintptr_ T and IntPtr_ T type