当前位置:网站首页>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;
}
};
边栏推荐
- Build your own minecraft server with fast parsing
- Summer challenge brings you to play harmoniyos multi terminal piano performance
- Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
- [paper reading] Tun det: a novel network for meridian ultra sound nodule detection
- Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
- P3304 [sdoi2013] diameter (diameter of tree)
- 企业应用业务场景,功能添加和修改C#源码
- Actual combat simulation │ JWT login authentication
- 多回路仪表在基站“转改直”方面的应用
- lambda表达式
猜你喜欢

How to use fast parsing to make IOT cloud platform

How to effectively monitor the DC column head cabinet

Two numbers replace each other

In June, the list of winners of "Moli original author program" was announced! Invite you to talk about the domestic database
![[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection](/img/25/e2366cabf00e55664d16455a6049e0.png)
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection

海思3559万能平台搭建:YUV422的踩坑记录

Netcore3.1 JSON web token Middleware

如何用快解析自制IoT云平台

图解网络:什么是网关负载均衡协议GLBP?

Microservice
随机推荐
如何有效对直流列头柜进行监测
IT转测试岗,从迷茫到坚定我究竟付出了什么?
Significance of acrel EMS integrated energy efficiency platform in campus construction
Parsing of XML
挖财学院开户安全的吗?开户怎么开?
电力运维云平台:开启电力系统“无人值班、少人值守”新模式
圖解網絡:什麼是網關負載均衡協議GLBP?
Expand your kubecl function
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
P4408 [NOI2003] 逃学的小孩(树的直径)
If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
【监控】zabbix
Paper notes multi UAV collaborative monolithic slam
Meet ThreadPoolExecutor
URLs and URIs
What is the difference between port mapping and port forwarding
2022.07.03(LC_6109_知道秘密的人数)
Life is changeable, and the large intestine covers the small intestine. This time, I can really go home to see my daughter-in-law...
华为200万年薪聘请数据治理专家!背后的千亿市场值得关注
Cross domain request