implement the isAnagram algrorithm