Amazon interview question

find if 2 strings are anagrams

Interview Answers

Anonymous

11 Aug 2012

Hash what, lol ? :))) You simply need to alphabetically sort characters in strings and then compare the result.

3

Anonymous

24 Sept 2012

think about the time complexity. Whats the time complexity of the sorting? NlogN And when using hash mapping, it can be only N. Mapping the string to an alphabet array, the index is the char and the value stores the frequency of the char. Hope it helps.

3

Anonymous

7 Apr 2015

Just reverse one string and then compare the result with other string.

Anonymous

29 Jul 2012

hash

Anonymous

2 Oct 2012

easiest way probably to reduce the characters to ascii, add them all together. If values are equal, they all contain the same characters. O(n)