当前位置:网站首页>Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
2022-07-07 05:31:00 【HERODING23】
Their thinking :
Count the number of all letters , And then according to balloon The number of five letters in a word , Count the maximum number of words that can be formed ( Take the minimum value that each letter can form the most words ), The code is as follows :
class Solution {
public:
int maxNumberOfBalloons(string text) {
vector<int> count(26, 0);
for(auto c : text) {
count[c - 'a'] ++;
}
int ans = min(count[1], min(count[0], min(count['l' - 'a'] / 2, min(count['o' - 'a'] / 2, count['n' - 'a']))));
return ans;
}
};
边栏推荐
- 2039: [Bluebridge cup 2022 preliminaries] Li Bai's enhanced version (dynamic planning)
- 数字化如何影响工作流程自动化
- A cool "ghost" console tool
- Scheduledexecutorservice timer
- Leetcode (417) -- Pacific Atlantic current problem
- Is it necessary to renew the PMP certificate?
- Tencent cloud database public cloud market ranks top 2!
- Batch size setting skills
- NPDP产品经理认证,到底是何方神圣?
- English语法_名词 - 所有格
猜你喜欢
A cool "ghost" console tool
Y58. Chapter III kubernetes from entry to proficiency - continuous integration and deployment (Sany)
照片选择器CollectionView
JVM(二十) -- 性能监控与调优(一) -- 概述
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
EGR-20USCM接地故障继电器
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
ssm框架的简单案例
Use, configuration and points for attention of network layer protocol (taking QoS as an example) when using OPNET for network simulation
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
随机推荐
Sorry, I've learned a lesson
[论文阅读] A Multi-branch Hybrid Transformer Network for Corneal Endothelial Cell Segmentation
Aidl and service
Mybaits之多表查询(联合查询、嵌套查询)
线程同步的两个方法
Photo selector collectionview
JHOK-ZBG2漏电继电器
What changes will PMP certification bring?
Annotation初体验
Auto. JS get all app names of mobile phones
项目经理如何凭借NPDP证书逆袭?看这里
LabVIEW is opening a new reference, indicating that the memory is full
做自媒体视频剪辑,专业的人会怎么寻找背景音乐素材?
MySQL数据库学习(8) -- mysql 内容补充
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Unity让摄像机一直跟随在玩家后上方
A cool "ghost" console tool
Leakage relay llj-100fs
Longest common subsequence (LCS) (dynamic programming, recursive)