当前位置:网站首页>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;
}
}
边栏推荐
- Cancer biopsy instruments and kits - market status and future development trends
- Sequence sorting of basic exercises of test questions
- 机器学习基础:用 Lasso 做特征选择
- 长文综述:大脑中的熵、自由能、对称性和动力学
- IPv6 experiment
- I don't know why it can't run in the project and how to change it
- MySQL statement learning record
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- mysql使用視圖報錯,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
- String hash, find the string hash value after deleting any character, double hash
猜你喜欢

I don't care about you. OKR or KPI, PPT is easy for you

Use classname to modify style properties

ES6 deletes an attribute in all array objects through map, deconstruction and extension operators

Douban scoring applet Part-3

Three layer switching ①

LeetCode226. Flip binary tree

0 basic learning C language - nixie tube dynamic scanning display

Solution of cursor thickening
![[turn] solve the problem of](/img/c2/368582a8ed26254409fe391899ba41.jpg)
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration

Introduction to Tianchi news recommendation: 4 Characteristic Engineering
随机推荐
SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
Typescript basic knowledge sorting
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
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)
Lightweight Pyramid Networks for Image Deraining
Skku| autonomous handover decision of UAV Based on deep reinforcement learning
C import Xls data method summary I (upload files and create Workbooks)
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?
Three layer switching ①
Jerry's modification setting status [chapter]
Three layer switching ②
How programmers find girlfriends through blind dates
Development of user-defined navigation bar in uniapp
[typora installation package] old typera installation package, free version
Day05 表格
Technical practice online fault analysis and solutions (Part 1)
Some other configurations on Huawei's spanning tree
Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?