Skip to content

Commit e0dcab9

Browse files
authored
Create First_letter_to_apper_twice.java
1 parent 0b27e28 commit e0dcab9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public char repeatedCharacter(String s) {
3+
HashSet<Character> c =new HashSet<>();
4+
char ch='a';
5+
for(int i=0;i<s.length();i++){
6+
ch = s.charAt(i);
7+
if(c.isEmpty()!=true && c.contains(ch)){
8+
return ch;
9+
}else{
10+
c.add(ch);
11+
}
12+
}
13+
return ch;
14+
}
15+
}

0 commit comments

Comments
 (0)