当前位置:网站首页>【leetcode】1189. Maximum number of "balloons"
【leetcode】1189. Maximum number of "balloons"
2022-07-06 03:56:00 【Chinese fir sauce_】
subject :
1189. “ balloon ” Maximum number of
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”.
Example 1:
Input :text = “nlaebolko”
Output :1
Example 2:
Input :text = “loonbalxballpoon”
Output :2
Example 3:
Input :text = “leetcode”
Output :0
Tips :
1 <= text.length <= 10^4
text All consist of lowercase English letters
class Solution {
public int maxNumberOfBalloons(String text) {
char[] ch = text.toCharArray();
Map<Character,Integer> map = new HashMap<>();
for(int i = 0; i < ch.length;i++){
map.put(ch[i],map.getOrDefault(ch[i],0) + 1 );
}
int res = 0;
int b = map.getOrDefault('b',0);
int a = map.getOrDefault('a',0);
int l = map.getOrDefault('l',0) / 2;
int o = map.getOrDefault('o',0) / 2;
int n = map.getOrDefault('n',0);
res = Math.min(a,b);
res = Math.min(res,l);
res = Math.min(res,o);
res = Math.min(res,n);
return res;
}
}
边栏推荐
- Take you to wechat applet development in 3 minutes
- 简易博客系统
- /usr/bin/gzip: 1: ELF: not found/usr/bin/gzip: 3: : not found/usr/bin/gzip: 4: Syntax error:
- LTE CSFB test analysis
- Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
- [meisai] meisai thesis reference template
- Ipv4中的A 、B、C类网络及子网掩码
- 【FPGA教程案例11】基于vivado核的除法器设计与实现
- C form application of C (27)
- Cubemx transplantation punctual atom LCD display routine
猜你喜欢

Do you know cookies, sessions, tokens?

ESP32(基于Arduino)连接EMQX的Mqtt服务器上传信息与命令控制

Thread sleep, thread sleep application scenarios
![[001] [stm32] how to download STM32 original factory data](/img/5a/02d87fe1409a9427180ecefb8326c6.jpg)
[001] [stm32] how to download STM32 original factory data

Recommended papers on remote sensing image super-resolution

Ks008 SSM based press release system

Factors affecting user perception

An article will give you a comprehensive understanding of the internal and external components of "computer"

登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES

Error 1045 (28000): access denied for user 'root' @ 'localhost' (using password: no/yes
随机推荐
P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]
[001] [stm32] how to download STM32 original factory data
Record the pit of NETCORE's memory surge
On Data Mining
2.2 fonctionnement stm32 GPIO
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
如何修改表中的字段约束条件(类型,default, null等)
Alibaba testers use UI automated testing to achieve element positioning
[FPGA tutorial case 11] design and implementation of divider based on vivado core
Blue Bridge Cup - Castle formula
Mapping between QoE and KQI
math_极限&微分&导数&微商/对数函数的导函数推导(导数定义极限法)/指数函数求导公式推导(反函数求导法则/对数求导法)
Determine which week of the month the day is
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
C language -- structs, unions, enumerations, and custom types
JS Vanke banner rotation chart JS special effect
A brief introduction to symbols and link libraries in C language
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Network security - Security Service Engineer - detailed summary of skill manual (it is recommended to learn and collect)