当前位置:网站首页>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;
}
};
边栏推荐
- 城市轨道交通站应急照明疏散指示系统设计
- Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
- The pit of sizeof operator in C language
- TS快速入门-函数
- Is the account opening link of Huatai Securities with low commission safe?
- 实战模拟│JWT 登录认证
- Get to know ROS for the first time
- 多回路仪表在基站“转改直”方面的应用
- 企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
- Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
猜你喜欢
Build your own minecraft server with fast parsing
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
2022.07.03(LC_6111_统计放置房子的方式数)
巩固表达式C# 案例简单变量运算
基本放大电路的学习
他做国外LEAD,用了一年时间,把所有房贷都还清了
【C】(笔试题)指针与数组,指针
城市轨道交通站应急照明疏散指示系统设计
青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区
用快解析内网穿透实现零成本自建网站
随机推荐
基于三维gis平台的消防系统运用
人脸识别5- insight-face-paddle-代码实战笔记
URL和URI
Application of fire fighting system based on 3D GIS platform
How to reduce the stock account Commission and stock speculation commission? Is it safe to open an online account
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
Best practice case of enterprise digital transformation: introduction and reference of cloud based digital platform system security measures
[IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
Design of emergency lighting evacuation indication system for urban rail transit station
ORB(Oriented FAST and Rotated BRIEF)
人生无常,大肠包小肠, 这次真的可以回家看媳妇去了。。。
如何将自己的代码作品快速存证,已更好的保护自己劳动成果
Basic points of the game setup of the points mall
Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
Fast analysis -- easy to use intranet security software
Expand your kubecl function
22-07-02周总结
Pytoch --- use pytoch to realize linknet for semantic segmentation
Nine Qi single chip microcomputer ny8b062d single key control four LED States