当前位置:网站首页>2022.02.13 - 238. Maximum number of "balloons"
2022.02.13 - 238. Maximum number of "balloons"
2022-07-06 08:21:00 【A CAI continues to work hard】
List of articles
1. subject

2. Ideas
(1) Hashtable
- Count the number of times each letter appears .
3. Code
public class Test {
public static void main(String[] args) {
}
}
class Solution {
public int maxNumberOfBalloons(String text) {
char[] chars = text.toCharArray();
int[] count = new int[26];
for (char c : chars) {
count[c - 'a']++;
}
int res = Integer.MAX_VALUE;
res = Math.min(res, count['a' - 'a']);
res = Math.min(res, count['b' - 'a']);
res = Math.min(res, count['l' - 'a'] >> 1);
res = Math.min(res, count['o' - 'a'] >> 1);
res = Math.min(res, count['n' - 'a']);
return res;
}
}
边栏推荐
- Leetcode question brushing record | 203_ Remove linked list elements
- Summary of MySQL index failure scenarios
- 【MySQL】锁
- 1. Color inversion, logarithmic transformation, gamma transformation source code - miniopencv from zero
- Introduction to number theory (greatest common divisor, prime sieve, inverse element)
- [cloud native] teach you how to build ferry open source work order system
- Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
- 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语言自定义类型:结构体
- ESP系列引脚說明圖匯總
猜你喜欢

Let the bullets fly for a while

Secure captcha (unsafe verification code) of DVWA range

wincc7.5下载安装教程(Win10系统)

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

From monomer structure to microservice architecture, introduction to microservices

Leetcode question brushing (5.28) hash table

Golang DNS 随便写写

Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation

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

How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
随机推荐
VMware virtualization cluster
Use br to back up tidb cluster data to S3 compatible storage
String to leading 0
1204 character deletion operation (2)
Use Alibaba icon in uniapp
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
化不掉的钟薛高,逃不出网红产品的生命周期
"Designer universe" Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers | national economic and Informa
备份与恢复 CR 介绍
Ruffian Heng embedded bimonthly, issue 49
[luatos-air551g] 6.2 repair: restart caused by line drawing
Vocabulary notes for postgraduate entrance examination (3)
Go learning notes (3) basic types and statements (2)
【MySQL】锁
将 NFT 设置为 ENS 个人资料头像的分步指南
C language custom type: struct
使用 Dumpling 备份 TiDB 集群数据到兼容 S3 的存储
"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
指针进阶---指针数组,数组指针
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