当前位置:网站首页>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';
}
}边栏推荐
- A method to prevent SYN flooding attacks -- syn cookies
- R language ggpubr package ggarrange function combines multiple images and annotates_ Figure function adds annotation, annotation and annotation information for the combined image, adds image labels fo
- 【ROS进阶篇】第九讲 URDF的编程优化Xacro使用
- “蔚来杯“2022牛客暑期多校训练营2 补题题解(G、J、K、L)
- scrapy 设置随机的user_agent
- 【六】地图框设置
- Ansible
- Excuse me, using data integration to import data from PostgreSQL to MySQL database, emoj appears in some data fields
- 基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
- scrapy爬虫爬取动态网站
猜你喜欢

MySQL exercise 2

Analysis of TCP packet capturing using Wireshark

2.1.2 机器学习的应用

Jenkins configuration pipeline

想要白嫖正则大全是吧?这一次给你个够!

Alibaba cloud technology expert Qin long: reliability assurance is a must - how to carry out chaos engineering on the cloud?

Fiddler packet capturing app
What does the software testing process include? What are the test methods?

Technical management essay

想要做好软件测试,可以先了解AST、SCA和渗透测试
随机推荐
numpy初识
Eureka usage record
Ansible
What is ci/cd?
Cmake learning notes (II) generation and use of Library
SSTI 模板注入漏洞总结之[BJDCTF2020]Cookie is so stable
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
Table partition of MySQL
The first scratch crawler
[fluent -- example] case 1: comprehensive example of basic components and layout components
【ROS进阶篇】第九讲 URDF的编程优化Xacro使用
【9】 Coordinate grid addition and adjustment
Numpy first acquaintance
【六】地图框设置
LeetCode 0133. 克隆图
Kyligence was selected into Gartner 2022 data management technology maturity curve report
pytorch环境配置及基础知识
Azure Devops (XIV) use azure's private nuget warehouse
Pytorch project practice - fashionmnist fashion classification
请问一下,使用数据集成从postgreSQL导数据到Mysql数据库,有部分数据的字段中出现emoj