Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- java
- geometry
- Number Theory
- database
- Matrix
- Binary Search
- Stack
- array
- implement
- 코딩테스트
- Tree
- 구현
- Method
- Class
- simulation
- sorting
- Data Structure
- bit manipulation
- hash table
- string
- greedy
- 코테
- Binary Tree
- Counting
- SQL
- 파이썬
- dynamic programming
- Math
- two pointers
- 자바
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2351. First Letter to Appear Twice 본문
1. Input
1) String s
2. Output
1) s에서 처음으로 2번 나오는 문자를 반환
3. Constraint
1) 2 <= s.length <= 100
2) s는 영어 소문자로 이루어져 있다.
3) s로 반드시 답이 나오게끔 되어 있다.
4. Example
Input: s = "abccbaacz" -> Output: "c"
Input: s = "abcdd" -> Output: "d"
5. Code
1) 첫 코드(2022/08/04)
import java.util.*;
List<Character> list = new ArrayList();
char c = ' ';
for(int i=0 ; i<s.length() ; i++){
if(!list.contains(s.charAt(i))) list.add(s.charAt(i));
else{
c = s.charAt(i);
break;
}
}
return c;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.2] 스킬트리 (0) | 2023.01.17 |
---|---|
[LeetCode/Easy] 104. Maximum Depth of Binary Tree (0) | 2023.01.17 |
[LeetCode/Easy] 2347. Best Poker Hand (0) | 2023.01.16 |
[LeetCode/Easy] 2341. Maximum Number of Pairs in Array (0) | 2023.01.16 |
[LeetCode/Easy] 2319. Check if Matrix Is X-Matrix (0) | 2023.01.16 |