当前位置:网站首页>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;
}
}
边栏推荐
- Use dumping to back up tidb cluster data to S3 compatible storage
- 【MySQL】锁
- Secure captcha (unsafe verification code) of DVWA range
- A Closer Look at How Fine-tuning Changes BERT
- Go learning notes (3) basic types and statements (2)
- Online yaml to CSV tool
- Upgrade tidb operator
- IoT -- 解读物联网四层架构
- Leetcode skimming (5.29) hash table
- 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
猜你喜欢
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
A Closer Look at How Fine-tuning Changes BERT
File upload of DVWA range
wincc7.5下载安装教程(Win10系统)
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
A Closer Look at How Fine-tuning Changes BERT
"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
[research materials] 2022 China yuancosmos white paper - Download attached
C语言 - 位段
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
随机推荐
NFT smart contract release, blind box, public offering technology practice -- jigsaw puzzle
Epoll and IO multiplexing of redis
What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
Learn Arduino with examples
C language custom type: struct
A Closer Look at How Fine-tuning Changes BERT
Leetcode question brushing (5.28) hash table
Go learning notes (3) basic types and statements (2)
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
[research materials] 2022 China yuancosmos white paper - Download attached
CAD ARX 获取当前的视口设置
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
[2022 广东省赛M] 拉格朗日插值 (多元函数极值 分治NTT)
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
Introduction to number theory (greatest common divisor, prime sieve, inverse element)
logback1.3. X configuration details and Practice
你想知道的ArrayList知识都在这
NFT smart contract release, blind box, public offering technology practice -- contract
Remote storage access authorization
指针和数组笔试题解析