当前位置:网站首页>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());
}
};
边栏推荐
- 基于Arduino制作非接触式测温仪
- 万字逐行解析与实现Transformer,并进行德译英实战(三)
- typescript26-字面量类型
- safari浏览器怎么导入书签
- 基于STM32设计的UNO卡牌游戏(双人、多人对战)
- PMP 项目质量管理
- MLP neural network, GRNN neural network, SVM neural network and deep learning neural network compare and identify human health and non-health data
- 开源许可证 GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
- 故乡的素描画
- ICML2022 | Deep Dive into Permutation-Sensitive Graph Neural Networks
猜你喜欢

程序员代码面试指南 CD15 生成窗口最大值数组

API Design Notes: The pimpl trick

56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)

力扣(LeetCode)212. 单词搜索 II(2022.07.31)

剑指 Offer 68 - II. 二叉树的最近公共祖先

开源许可证 GPL、BSD、MIT、Mozilla、Apache和LGPL的区别

智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”

Pyspark机器学习:向量及其常用操作

Message queue MySQL table for storing message data

Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
随机推荐
Error using ts-node
typescript24-类型推论
This article takes you to understand the past and present of Mimir, Grafana's latest open source project
Pyspark机器学习:向量及其常用操作
typescript19-对象可选参数
A way to deal with infinite debugger
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
EntityFramework saves to SQLServer decimal precision is lost
Mysql基础篇(Mysql数据类型)
认真对待每一个时刻
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
typescript28 - value of enumeration type and data enumeration
基于Arduino制作非接触式测温仪
项目风险管理必备内容总结
状态压缩dp
25. Have you been asked these three common interview questions?
[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce
罗技鼠标体验记录
MySQL3
【愚公系列】2022年07月 Go教学课程 025-递归函数