当前位置:网站首页>2022.07.24 (lc_6124_the first letter that appears twice)
2022.07.24 (lc_6124_the first letter that appears twice)
2022-07-25 12:39:00 【Leeli9316】

Method : Count
class Solution {
public char repeatedCharacter(String s) {
int[] counter = new int[26];
for (char ch : s.toCharArray()) {
counter[ch - 'a']++;
if (counter[ch - 'a'] > 1) {
return ch;
}
}
return 'a';
}
}Method 2 : Hashtable
class Solution {
public char repeatedCharacter(String s) {
Set<Character> set = new HashSet<>();
for (char ch : s.toCharArray()) {
if (!set.add(ch)) {
return ch;
}
}
return 'a';
}
}边栏推荐
- intval md5绕过之[WUSTCTF2020]朴实无华
- 艰辛的旅程
- 请问一下,使用数据集成从postgreSQL导数据到Mysql数据库,有部分数据的字段中出现emoj
- 【ROS进阶篇】第九讲 URDF的编程优化Xacro使用
- R language uses the ggarrange function of ggpubr package to combine multiple images, and uses the ggexport function to save the visual images in JPEG format (width parameter specifies width, height pa
- 深度学习MEMC插帧论文列表paper list
- Azure Devops (XIV) use azure's private nuget warehouse
- Fiddler抓包APP
- 【Rust】引用和借用,字符串切片 (slice) 类型 (&str)——Rust语言基础12
- 微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告
猜你喜欢

Communication bus protocol I: UART

Build a series of vision transformer practices, and finally meet, Timm library!

Zuul gateway use

If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing

微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告

2022.07.24(LC_6125_相等行列对)

Introduction to the scratch crawler framework

防范SYN洪泛攻击的方法 -- SYN cookie

Jenkins configuration pipeline

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
随机推荐
[advanced C language] dynamic memory management
Maskgae: masked graph modeling meets graph autoencoders
Introduction to the scratch crawler framework
Script set random user_ agent
Fiddler抓包APP
推荐系统-协同过滤在Spark中的实现
scrapy爬虫爬取动态网站
如何从远程访问 DMS数据库?IP地址是啥?用户名是啥?
[shutter -- layout] stacked layout (stack and positioned)
想要白嫖正则大全是吧?这一次给你个够!
If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing
logstash
【四】布局视图和布局工具条使用
【10】 Scale bar addition and adjustment
Eureka usage record
Table partition of MySQL
How to access DMS database remotely? What is the IP address? What is the user name?
深度学习MEMC插帧论文列表paper list
[ROS advanced chapter] Lecture 9 programming optimization of URDF and use of xacro
防范SYN洪泛攻击的方法 -- SYN cookie