Skip to content

Commit 1740971

Browse files
committed
feat: add Valid Anagram 2
1 parent c0e167c commit 1740971

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

TypeScript/242.valid-anagram.ts

+8
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ function isAnagram(s: string, t: string): boolean {
1212

1313
return frequency.findIndex((c) => c !== 0) === -1;
1414
}
15+
16+
function isAnagram2(s: string, t: string): boolean {
17+
if (s.length !== t.length) {
18+
return false;
19+
}
20+
21+
return s.split("").sort().join("") === t.split("").sort().join("");
22+
}

0 commit comments

Comments
 (0)