Improve isAnagram from O(m log m) to O(m)