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
- Matrix
- array
- 코테
- 코딩테스트
- implement
- Class
- Tree
- sorting
- two pointers
- geometry
- 구현
- bit manipulation
- string
- java
- greedy
- 자바
- Math
- dynamic programming
- Binary Tree
- SQL
- Method
- Number Theory
- database
- 파이썬
- hash table
- Binary Search
- Counting
- Stack
- Data Structure
- simulation
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 242. Valid Anagram 본문
1. Input
1) 문자열 s
2) 문자열 t
2. Output
1) t가 s의 anagram이면 true 반환
2) 아니면 false 반환
3) anagram은 본래의 문자열의 순서를 바꿔서 새로 만든 문자열을 뜻함
3. Constraint
1) 1 <= s.length, t.length <= 5 * 104
2) s와 t는 영어 소문자로만 구성되어 있음
4. Example
Input: s = "anagram", t = "nagaram" -> Output: true
Input: s = "rat", t = "car" -> Output: false
5. Code
1) 첫 코드(2022/07/28)
if(s.length()!=t.length())
return false;
String[] ss = s.split("");
String[] tt = t.split("");
Arrays.sort(ss);
Arrays.sort(tt);
for(int i=0 ; i<s.length() ; i++)
if(!ss[i].equals(tt[i]))
return false;
return true;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 263. Ugly Number (0) | 2022.10.14 |
---|---|
[LeetCode/Easy] 258. Add Digits (0) | 2022.10.14 |
[LeetCode/Easy] 231. Power of Two (0) | 2022.10.13 |
[LeetCode/Easy] 217. Contains Duplicate (0) | 2022.10.12 |
[LeetCode/Easy] 191. Number of 1 Bits (0) | 2022.10.12 |