Pregunta de entrevista de Amazon

find if 2 strings are anagrams

Respuestas de entrevistas

Anónimo

11 ago 2012

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

3

Anónimo

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

Anónimo

7 abr 2015

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

Anónimo

29 jul 2012

hash

Anónimo

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)