当前位置:网站首页>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());
}
};
边栏推荐
- Flutter Tutorial 01 Configure the environment and run the demo program (tutorial includes source code)
- 出现Command ‘vim‘ is available in the following places,vim: command not found等解决方法
- 智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”
- [FPGA tutorial case 43] Image case 3 - image sobel edge extraction through verilog, auxiliary verification through MATLAB
- 25. 这三道常见的面试题,你有被问过吗?
- 【kali-信息收集】枚举——DNS枚举:DNSenum、fierce
- MySQL4
- 博客系统(完整版)
- Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
- 罗技鼠标体验记录
猜你喜欢
2022-07-31: Given a graph with n points and m directed edges, you can use magic to turn directed edges into undirected edges, such as directed edges from A to B, with a weight of 7.After casting the m
UE4 模型OnClick事件不生效的两种原因
Passive anti-islanding-UVP/OVP and UFP/OFP passive anti-islanding model simulation based on simulink
数组问题之《两数之和》以及《三数之和 》
typescript27-枚举类型呢
ICML2022 | Deep Dive into Permutation-Sensitive Graph Neural Networks
PAT乙级 1002 写出这个数
Logitech Mouse Experience Record
程序员代码面试指南 CD15 生成窗口最大值数组
Pyspark机器学习:向量及其常用操作
随机推荐
产品经理访谈 | 第五代验证码的创新与背景
【愚公系列】2022年07月 Go教学课程 025-递归函数
This article takes you to understand the past and present of Mimir, Grafana's latest open source project
typescript21-接口和类型别名的对比
Pyspark机器学习:向量及其常用操作
PMP子过程定义总结
Input input box cursor automatically jumps to the last bug after the previous input
PMP 项目资源管理
Message Queuing Message Storage Design (Architecture Camp Module 8 Jobs)
李迟2022年7月工作生活总结
初识shell脚本
UE4 模型OnClick事件不生效的两种原因
2022-07-31: Given a graph with n points and m directed edges, you can use magic to turn directed edges into undirected edges, such as directed edges from A to B, with a weight of 7.After casting the m
最新 955 不加班的公司名单
UE4 rays flashed from mouse position detection
请问表格储存中用sql只能查询到主键列,ots sql非主键不支持吗?
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
Flutter Tutorial 02 Introduction to Flutter Desktop Program Development Tutorial Run hello world (tutorial includes source code)
Make your Lottie support word wrapping in text fields
MySQL-DML语言-数据库操作语言-insert-update-delete-truncate