Return true if t is an anagram of s, i.e. uses exactly the same letters the same number of times.
For lowercase letters, a fixed array of 26 counters does the same job as a map. Increment for s and decrement for t in the same loop.
1function isAnagram(s: string, t: string): boolean {2if (s.length !== t.length) return false;3const cnt = new Array(26).fill(0);4for (let i = 0; i < s.length; i++) {5cnt[s.charCodeAt(i) - 97]++;6cnt[t.charCodeAt(i) - 97]--;7}8return cnt.every((c) => c === 0);9}
+1 'a', −1 'n'.
Space: play/pause · ←/→: step