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 |
Tags
- Number Theory
- Matrix
- hash table
- Class
- string
- 구현
- Tree
- database
- array
- implement
- greedy
- 코딩테스트
- 자바
- 코테
- 파이썬
- geometry
- Counting
- Method
- Stack
- Math
- Data Structure
- sorting
- java
- two pointers
- dynamic programming
- SQL
- simulation
- bit manipulation
- Binary Search
- Binary Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 389. Find the Difference 본문
1. Input
1) String s
2) String t
2. Output
1) s가 t가 되기 위해서 추가해야 하는 문자를 반환
3. Constraint
1) 0 <= s.length <= 1000
2) t.length == s.length + 1
3) s와 t는 영어 소문자로만 이루어져 있다.
4. Example
Input: s = "abcd", t = "abcde" -> Output: "e"
5. Code
1) 첫 코드(2023/05/18)
class Solution {
public char findTheDifference(String s, String t) {
ArrayList<Character> list = new ArrayList<Character>();
for(int i=0 ; i<t.length() ; i++)
list.add(t.charAt(i));
for(int i=0 ; i<s.length() ; i++)
list.remove(Character.valueOf(s.charAt(i)));
return list.get(0);
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 392. Is Subsequence (0) | 2023.05.18 |
---|---|
[LeetCode/Easy] 303. Range Sum Query - Immutable (0) | 2023.05.18 |
[LeetCode/Easy] 387. First Unique Character in a String (0) | 2023.05.18 |
[LeetCode/Easy] 349. Intersection of Two Arrays (0) | 2023.05.18 |
[백준 온라인 저지] 11653. 소인수분해 (0) | 2023.05.16 |