Anagram Check
A word is anagram of another word if we can rearrange the letter to create that word.
For example: "spar"
is anagram of "rasp"
.
To check the anagram we can use Counter:
def isAnagram(wordA, wordB):
return Counter(wordA) == Counter(wordB)
Time complexity (from dict compare):
- if has different length
- if has same length