Skip to content

Commit 64c2bdf

Browse files
committed
valid-anagram
1 parent 25ed955 commit 64c2bdf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

valid-anagram/hjeomdev.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public boolean isAnagram(String s, String t) {
3+
if (s.length() != t.length()) {
4+
return false;
5+
}
6+
7+
String[] sList = s.split("");
8+
Arrays.sort(sList);
9+
String[] tList = t.split("");
10+
Arrays.sort(tList);
11+
12+
for (int i = 0; i < s.length(); i++) {
13+
// System.out.println(sList[i] + " " + tList[i]);
14+
if (!sList[i].equals(tList[i])) {
15+
return false;
16+
}
17+
}
18+
19+
return true;
20+
}
21+
}

0 commit comments

Comments
 (0)