当前位置:网站首页>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());
}
};
边栏推荐
- 基于ProXmoX VE的虚拟化家庭服务器(篇一)—ProXmoX VE 安装及基础配置
- TypeScript simplifies running ts-node
- Valentine's Day Romantic 3D Photo Wall [with source code]
- PMP 项目质量管理
- 深圳某游戏研发公司给每个工位都装监控,网友:堪比坐牢!
- 文件的异步读写
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
- [FPGA tutorial case 43] Image case 3 - image sobel edge extraction through verilog, auxiliary verification through MATLAB
- typescript28-枚举类型的值以及数据枚举
- What is dynamic programming and what is the knapsack problem
猜你喜欢
API Design Notes: The pimpl trick
Excel做题记录——整数规划优化模型
律师解读 | 枪炮还是玫瑰?从大厂之争谈元宇宙互操作性
TypeScript simplifies running ts-node
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
故乡的素描画
MLP neural network, GRNN neural network, SVM neural network and deep learning neural network compare and identify human health and non-health data
干货!如何使用仪表构造SRv6-TE性能测试环境
Difference Between Compiled and Interpreted Languages
PAT乙级 1002 写出这个数
随机推荐
leetcode:126. Word Solitaire II
报错:AttributeError: module ‘matplotlib’ has no attribute ‘figure’
万字逐行解析与实现Transformer,并进行德译英实战(一)
深圳某游戏研发公司给每个工位都装监控,网友:堪比坐牢!
ModuleNotFoundError: No module named ‘tensorflow.keras‘报错信息的解决方法
PMP 相关方管理必背总结
产品经理访谈 | 第五代验证码的创新与背景
typescript26 - literal types
6-23漏洞利用-postgresql代码执行利用
Mysql基础篇(Mysql数据类型)
Flutter Tutorial 02 Introduction to Flutter Desktop Program Development Tutorial Run hello world (tutorial includes source code)
Li Chi's work and life summary in July 2022
typescript27 - what about enumeration types
Excel record of integer programming optimization model to solve the problem
Message Queuing Message Storage Design (Architecture Camp Module 8 Jobs)
25. Have you been asked these three common interview questions?
请问表格储存中用sql只能查询到主键列,ots sql非主键不支持吗?
56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
SQL Analysis of ShardingSphere
typescript23-tuple