For example,
XOR solution will fail on test cases like this:
7
trees bike cars steer arcs arrrcs carrrs
The reason is that hash code of "arcs" and "arrrcs" is the same and they are not anagrams. You should not keep hash code as a key of your HashMap because of collisions.