Skip to content

Commit 4408e31

Browse files
committed
valid anagram solution
1 parent 42e2dd2 commit 4408e31

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

valid-anagram/yoonthecoder.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var isAnagram = function (s, t) {
2+
const sArray = [];
3+
const tArray = [];
4+
5+
for (i = 0; i < s.length; i++) {
6+
sArray.push(s.charAt(i));
7+
}
8+
for (i = 0; i < t.length; i++) {
9+
tArray.push(t.charAt(i));
10+
}
11+
12+
return JSON.stringify(sArray.sort()) === JSON.stringify(tArray.sort());
13+
};
14+
15+
// Time complexity : O(nlogn)
16+
// Space complexity : O(n)

0 commit comments

Comments
 (0)