[VIDEO] Visualization of Counting Character Frequencies
https://youtu.be/vYNRXZ4GXPg\n\nThe simplest approach would be to sort each string and compare them to each other.  If they are the same,  then they are anagram
https://youtu.be/vYNRXZ4GXPg\n\nThe simplest approach would be to sort each string and compare them to each other.  If they are the same,  then they are anagrams.  The drawback to this method is that since the cost of sorting can be no less than O(n log n), if the length of the longer string is n, then this strategy runs in O(n log n) time.\n\nThere\'s actually no reason why the strings need to be in sorted order though. All we need to know are the character frequencies of each string.  In other words, if each string uses the same number of each character, then they are anagrams of each other.\n\nWe can use a hash table (dictionary) to keep track of the character frequencies of each string.  Then, if the contents of each dictionary are equal to each other, then the two strings are anagrams.  Since we only have to iterate through each string once, this runs in O(n) time.\n\nVariations:\nIf you wanted to save space, you could use one dictionary instead of two.  Then, for the second string, you would decrement the character counts instead of incrementing them.  If all the values end up as 0, then the strings are anagrams\n\nYou could also use an array instead to avoid the complex hash calculations required when using hash tables.  "a" would map to index 0, "b" maps to index 1, etc.\n\n# Code\n```\nclass Solution:\n    def isAnagram(self, s: str, t: str) -> bool:\n        if len(s) != len(t):\n            return False\n\n        s_freq = {}\n        t_freq = {}\n        for char in s:\n            s_freq[char] = s_freq.get(char, 0) + 1\n        for char in t:\n            t_freq[char] = t_freq.get(char, 0) + 1\n\n        return s_freq == t_freq\n```
['Hash Table', 'String', 'Python', 'Python3']