当前位置:网站首页>1189. Maximum number of "balloons"
1189. Maximum number of "balloons"
2022-07-05 00:20:00 【Phoenix_ ZengHao】
subject
1189.“ balloon ” Maximum number of
The main idea of the topic
Give you a string text, You need to use text To piece together as many words as possible “balloon”( balloon ).
character string text Each letter in can only be used once at most . Please return the maximum number of words you can piece together “balloon”.
Examples

Data scale

Ideas
Considering the composition of words b a l l o o n balloon balloon, There is no need to care about their order . And it is clear that each letter can only be used once , So count the number of each letter directly , Then the number of words that can be formed at last is m i n ( b , a , l / 2 , o / 2 , n ) min(b,a,l/2,o/2,n) min(b,a,l/2,o/2,n).
Code
class Solution {
public:
int vis[30];
int maxNumberOfBalloons(string text) {
for(int i=0;i<text.length();i++){
vis[text[i]-'a']++;
}
int ans=min(vis[1],min(vis[0],min(vis['l'-'a']/2,min(vis['o'-'a']/2,vis['n'-'a']))));
return ans;
}
};
边栏推荐
- In June, the list of winners of "Moli original author program" was announced! Invite you to talk about the domestic database
- Microservice
- The pit of sizeof operator in C language
- Business implementation - the log is written to the same row of data
- Illustrated network: what is gateway load balancing protocol GLBP?
- 企业应用业务场景,功能添加和修改C#源码
- 海思3559万能平台搭建:YUV422的踩坑记录
- Five papers recommended for the new development of convolutional neural network in deep learning
- AcWing164. 可达性统计(拓扑排序+bitset)
- Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
猜你喜欢

微服务(Microservice)那点事儿

ORB(Oriented FAST and Rotated BRIEF)

Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
Date time type and format in MySQL

JS how to realize array to tree

Application of fire fighting system based on 3D GIS platform

OpenHarmony资源管理详解

Deux nombres se remplacent

【雅思阅读】王希伟阅读P4(matching1)

IT转测试岗,从迷茫到坚定我究竟付出了什么?
随机推荐
Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
The pit of sizeof operator in C language
Is the account opening link of Huatai Securities with low commission safe?
P3304 [SDOI2013]直径(树的直径)
电力运维云平台:开启电力系统“无人值班、少人值守”新模式
Meet ThreadPoolExecutor
GDB常用命令
(script) one click deployment of any version of redis - the way to build a dream
Using fast parsing intranet penetration to realize zero cost self built website
实战模拟│JWT 登录认证
[paper reading] Tun det: a novel network for meridian ultra sound nodule detection
What did I pay for it transfer to testing post from confusion to firmness?
如何有效对直流列头柜进行监测
Detailed explanation of openharmony resource management
Significance of acrel EMS integrated energy efficiency platform in campus construction
Actual combat simulation │ JWT login authentication
It's too convenient. You can complete the code release and approval by nailing it!
Application of fire fighting system based on 3D GIS platform
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system