deno.land / x / masx200_leetcode_test@10.6.5 / valid-anagram / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export default function isAnagram(s: string, t: string): boolean { if (s.length !== t.length) { return false; }
const map: Record<string, number | undefined> = {}; for (const c of s) { map[c] = 1 + (map[c] ?? 0); } for (const c of t) { const count = -1 + (map[c] ?? 0); map[c] = count; if (count < 0) return false; } return Object.values(map).every((a) => a === 0);}
masx200_leetcode_test

Version Info

Tagged at
a year ago