Anagram program in python with O(n)