We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 026e627 commit 91742b0Copy full SHA for 91742b0
valid-anagram/YeomChaeEun.ts
@@ -0,0 +1,17 @@
1
+function isAnagram(s: string, t: string): boolean {
2
+ if(s.length !== t.length) return false
3
+
4
+ let counter = {}
5
+ for(let sValue of s) {
6
+ if(!counter[sValue]) { counter[sValue] = 1 }
7
+ else { counter[sValue]++ }
8
9
+ }
10
11
+ for(let tValue of t) {
12
+ if(!counter[tValue]) return false
13
+ else counter[tValue]--
14
15
16
+ return Object.values(counter).findIndex(value => value !== 0) < 0;
17
+};
0 commit comments