function isAnagram(s, t) {
if (s.length !== t.length) return false;
const map = {};
for (let ch of s) map[ch] = (map[ch] || 0) + 1;
for (let ch of t) {
if (!map[ch]) return false;
map[ch]--;
}
return true;
}
Explanation: We count character frequencies using a hash map. If both strings have the same frequency for every character, they are anagrams.
β± O(n) | πΎ O(1)