当前位置:网站首页>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());
}
};
边栏推荐
- 律师解读 | 枪炮还是玫瑰?从大厂之争谈元宇宙互操作性
- Excel record of integer programming optimization model to solve the problem
- A way to deal with infinite debugger
- 智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”
- 阿叶的目标
- SQL Analysis of ShardingSphere
- 怀念故乡的月亮
- Flutter Tutorial 02 Introduction to Flutter Desktop Program Development Tutorial Run hello world (tutorial includes source code)
- Flink 1.13 (8) CDC
- 报错:AttributeError: module ‘matplotlib’ has no attribute ‘figure’
猜你喜欢
随机推荐
Make your Lottie support word wrapping in text fields
typescript27 - what about enumeration types
PMP 相关方管理必背总结
Game Theory (Depu) and Sun Tzu's Art of War (42/100)
6-23漏洞利用-postgresql代码执行利用
挑战52天背完小猪佩奇(第01天)
Mysql基础篇(Mysql数据类型)
(Codeforce 757)E. Bash Plays with Functions(积性函数)
UE4 从鼠标位置射出射线检测
How to write a high-quality digital good article recommendation
Unknown Bounded Array
RSA主要攻击方法
Immutable
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
Write a method to flatten an array and deduplicate and sort it incrementally
万字逐行解析与实现Transformer,并进行德译英实战(二)
PMP 80个输入输出总结
API设计笔记:pimpl技巧
怀念故乡的月亮
云服务器下载安装mongo数据库并远程连接详细图文版本(全)