Sherlock and Anagrams

  • + 3 comments

    You can also optimize space by using a single array to count the char frequencies. Just add 1 for a and subtract 1 for b, then check if everything is at 0;