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 b5b6294 commit 22e4088Copy full SHA for 22e4088
1 file changed
valid-anagram/j2h30728.ts
@@ -0,0 +1,12 @@
1
+function isAnagram(s: string, t: string): boolean {
2
+ const obj = {};
3
+ for (let i = 0; i < s.length; i++) {
4
+ obj[s[i]] = (obj[s[i]] || 0) + 1;
5
+ }
6
+
7
+ for (let i = 0; i < t.length; i++) {
8
+ obj[t[i]] -= 1;
9
10
11
+ return Object.values(obj).filter((value) => value !== 0).length === 0;
12
+}
0 commit comments