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 |
Tags
- Method
- simulation
- 자바
- Binary Search
- hash table
- string
- array
- Binary Tree
- implement
- dynamic programming
- sorting
- Number Theory
- Stack
- greedy
- Data Structure
- Counting
- two pointers
- Tree
- Class
- java
- bit manipulation
- Matrix
- 코딩테스트
- 파이썬
- 코테
- Math
- SQL
- database
- 구현
- geometry
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 |