当前位置:网站首页>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());
}
};
边栏推荐
- typescript25-类型断言
- Character encoding and floating point calculation precision loss problem
- Mysql基础篇(Mysql数据类型)
- UE4 模型OnClick事件不生效的两种原因
- 初识shell脚本
- Message queue MySQL table for storing message data
- The Flow Of Percona Toolkit pt-table-checksum
- UE4 制作遇到的问题
- Write a method to flatten an array and deduplicate and sort it incrementally
- The Principle Of Percona Toolkit Nibble Algorithm
猜你喜欢

状态压缩dp

Article summary: the basic model of VPN and business types

UE4 模型OnClick事件不生效的两种原因

微软 Win10 照片磁贴后的又一“刺客”,谷歌 Chrome 浏览器将在新标签页展示用户照片

typescript28 - value of enumeration type and data enumeration

高数 | 【重积分】线面积分880例题
![[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce](/img/97/bbe7c2af0ff8bcb5222b9105d80c73.png)
[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce

Difference Between Compiled and Interpreted Languages

出现Command ‘vim‘ is available in the following places,vim: command not found等解决方法

Pyspark机器学习:向量及其常用操作
随机推荐
律师解读 | 枪炮还是玫瑰?从大厂之争谈元宇宙互操作性
UE4 rays flashed from mouse position detection
Optional parameters typescript19 - object
风险策略调优中重要的三步分析法
阿叶的目标
解决ffmpeg使用screen-capture-recorder录屏,有屏幕缩放的情况下录不全的问题
【云原生之kubernetes实战】kubernetes集群的检测工具——popeye
【愚公系列】2022年07月 Go教学课程 025-递归函数
Mysql基础篇(约束)
出现Command ‘vim‘ is available in the following places,vim: command not found等解决方法
一个往年的朋友
云服务器下载安装mongo数据库并远程连接详细图文版本(全)
TIM登陆时提示00001(TIM00001)
7 行代码搞崩溃 B 站,原因令人唏嘘!
What is a programming language
typescript21-接口和类型别名的对比
Mysql基础篇(Mysql数据类型)
Difference Between Compiled and Interpreted Languages
PMP工具与技术总结
产品经理访谈 | 第五代验证码的创新与背景