当前位置:网站首页>LeetCode 1189. “气球” 的最大数量
LeetCode 1189. “气球” 的最大数量
2022-08-01 04:49:00 【PUdd】
思路:统计
构成“balloon”需要1个b,一个a,两个l,两个o,一个n,统计即可。将l,o除以2,返回a,b,l,o,n中数量最小值。
代码
class Solution {
public:
int maxNumberOfBalloons(string text)
{
vector <int> ablonArray(5);
for(int i =0; i < text.length(); i++)
{
switch(text[i])
{
case 'a':
ablonArray[0]+=1;
break;
case 'b':
ablonArray[1]+=1;
break;
case 'l':
ablonArray[2]+=1;
break;
case 'o':
ablonArray[3]+=1;
break;
case 'n':
ablonArray[4]+=1;
break;
default:
break;
};
}
ablonArray[2]/=2;
ablonArray[3]/=2;
return *min_element(ablonArray.begin(), ablonArray.end());
}
};
边栏推荐
猜你喜欢

数组问题之《下一个排列》、《旋转图像》以及二分查找之《搜索二维矩阵》

干货!如何使用仪表构造SRv6-TE性能测试环境

typescript27 - what about enumeration types

UE4 从鼠标位置射出射线检测

safari浏览器怎么导入书签

typescript28 - value of enumeration type and data enumeration

今日睡眠质量记录68分

Message queue design based on mysql

Input input box cursor automatically jumps to the last bug after the previous input

typescript28-枚举类型的值以及数据枚举
随机推荐
Dynamic Programming 01 Backpack
UE4 模型OnClick事件不生效的两种原因
lambda
Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
雪糕和轮胎
万字逐行解析与实现Transformer,并进行德译英实战(二)
(Codeforce 757)E. Bash Plays with Functions(积性函数)
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
MySQL3
Flutter Tutorial 01 Configure the environment and run the demo program (tutorial includes source code)
怀念故乡的月亮
数组问题之《两数之和》以及《三数之和 》
What is a programming language
【愚公系列】2022年07月 Go教学课程 023-Go容器之列表
Message queue MySQL table for storing message data
"ArchSummit: The cry of the times, technical people can hear"
万字逐行解析与实现Transformer,并进行德译英实战(三)
Advice given by experts with four years of development experience in Flutter tutorial
PMP 项目质量管理
typescript21 - Comparison of Interfaces and Type Aliases