当前位置:网站首页>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());
}
};
边栏推荐
- typescript26-字面量类型
- 【kali-信息收集】枚举——DNS枚举:DNSenum、fierce
- 解决ffmpeg使用screen-capture-recorder录屏,有屏幕缩放的情况下录不全的问题
- How to write a high-quality digital good article recommendation
- 万字逐行解析与实现Transformer,并进行德译英实战(二)
- Typescript20 - interface
- Excuse me, only primary key columns can be queried using sql in table storage. Does ots sql not support non-primary keys?
- What is a programming language
- safari浏览器怎么导入书签
- 「以云为核,无感极速」顶象第五代验证码
猜你喜欢

Optional parameters typescript19 - object

What is dynamic programming and what is the knapsack problem

基于Arduino制作非接触式测温仪

Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation

基于ProXmoX VE的虚拟化家庭服务器(篇一)—ProXmoX VE 安装及基础配置

Typescript20 - interface

7月编程排行榜来啦!这次有何新变化?

safari浏览器怎么导入书签

(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
![[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce](/img/97/bbe7c2af0ff8bcb5222b9105d80c73.png)
[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce
随机推荐
挑战52天背完小猪佩奇(第01天)
这里有110+公开的专业数据集
August 22 Promotion Ambassador Extra Reward Rules
button remove black frame
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
The method of solving stored procedure table name passing through variable in mysql
【愚公系列】2022年07月 Go教学课程 024-函数
typescript26-字面量类型
What is dynamic programming and what is the knapsack problem
typescript27 - what about enumeration types
7 行代码搞崩溃 B 站,原因令人唏嘘!
Excel record of integer programming optimization model to solve the problem
typescript19-对象可选参数
API设计笔记:pimpl技巧
【堆】小红的数组
干货!如何使用仪表构造SRv6-TE性能测试环境
博客系统(完整版)
MySQL3
万字逐行解析与实现Transformer,并进行德译英实战(二)