当前位置:网站首页>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';
}
}边栏推荐
- 我想问DMS有没有定时备份某一个数据库的功能?
- 启牛开的证券账户安全吗?是怎么开账户的
- Leetcode 0133. clone diagram
- “蔚来杯“2022牛客暑期多校训练营2 补题题解(G、J、K、L)
- JS 将伪数组转换成数组
- Pytorch environment configuration and basic knowledge
- Communication bus protocol I: UART
- 公安部:国际社会普遍认为中国是世界上最安全的国家之一
- Alibaba cloud technology expert Qin long: reliability assurance is a must - how to carry out chaos engineering on the cloud?
- Dr. water 2
猜你喜欢
随机推荐
[shutter -- layout] stacked layout (stack and positioned)
Software testing interview question: Please list the testing methods of several items?
Analysis of TCP packet capturing using Wireshark
Pytorch project practice - fashionmnist fashion classification
MySQL exercise 2
Pytorch main module
R language ggplot2 visualization: visualize the scatter diagram, add text labels to some data points in the scatter diagram, and use geom of ggrep package_ text_ The repl function avoids overlapping l
What is ci/cd?
我在源头SQLServer里面登记绝对删除的数据,传到MaxComputer,在数据清洗的时候写绝对
numpy初识
技术管理杂谈
1.1.1 欢迎来到机器学习
Leetcode 0133. clone diagram
Eureka registration center opens password authentication - record
力扣 83双周赛T4 6131.不可能得到的最短骰子序列、303 周赛T4 6127.优质数对的数目
If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing
阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
Kyligence 入选 Gartner 2022 数据管理技术成熟度曲线报告
mysql的表分区









