Skip to content

Commit a4b29c7

Browse files
committed
valid-anagram solution
1 parent 0fc7ec8 commit a4b29c7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

valid-anagram/kimjunyoung90.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class kimjunyoung90 {
2+
public boolean isAnagram(String s, String t) {
3+
if(s.length() != t.length()) return false;
4+
5+
int[] count = new int[26];
6+
7+
for (int i = 0; i < s.length(); i++) {
8+
count[s.charAt(i) - 'a']++;
9+
count[t.charAt(i) - 'a']--;
10+
}
11+
12+
for(int c : count) {
13+
if (c != 0) return false;
14+
}
15+
16+
return true;
17+
}
18+
}

0 commit comments

Comments
 (0)