当前位置:网站首页>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;
}
};
边栏推荐
- JHOK-ZBG2漏电继电器
- How does redis implement multiple zones?
- How can project managers counter attack with NPDP certificates? Look here
- Complete code of C language neural network and its meaning
- DJ-ZBS2漏电继电器
- Vector and class copy constructors
- 2039: [蓝桥杯2022初赛] 李白打酒加强版 (动态规划)
- Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
- Knapsack problem (01 knapsack, complete knapsack, dynamic programming)
- Wonderful express | Tencent cloud database June issue
猜你喜欢
数字化如何影响工作流程自动化
How Alibaba cloud's DPCA architecture works | popular science diagram
[JS component] date display.
DOM node object + time node comprehensive case
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
JVM (19) -- bytecode and class loading (4) -- talk about class loader again
QT simple layout box model with spring
Is it necessary to renew the PMP certificate?
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
随机推荐
最长回文子串(动态规划)
Egr-20uscm ground fault relay
论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
漏电继电器JELR-250FG
Auto. JS get all app names of mobile phones
As we media, what websites are there to download video clips for free?
JVM(二十) -- 性能监控与调优(一) -- 概述
How can project managers counter attack with NPDP certificates? Look here
导航栏根据路由变换颜色
Life experience of an update statement
高压漏电继电器BLD-20
The navigation bar changes colors according to the route
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
一条 update 语句的生命经历
SQL injection - secondary injection and multi statement injection
np. random. Shuffle and np Use swapaxis or transfer with caution
ThinkPHP Association preload with
纪念下,我从CSDN搬家到博客园啦!
Linkedblockingqueue source code analysis - initialization
ssm框架的简单案例