Pergunta de entrevista da empresa Yelp

Write an function to compute if a string is an anagram. Time and space complexity and how to optimize it.