employer cover photo
employer logo
employer logo

Amazon Lab126

Part of Amazon

Is this your company?

Amazon Lab126 Interview Question

Write a program to determine if a character array is an anagram of another character array.

Interview Answers

Anonymous

Jun 24, 2013

Use an additional int array which has the length of all characters. Traverse the first array. For each character, add one to the corresponding element(index = (int)(character)) of the int array. Then, for the second array, traverse it and minus one for the corresponding element. Then, traverse the int array and check whether every element is 0.

2

Anonymous

Apr 11, 2012

Its easy We have first do a sorting operation. Sort the array,then check for equal lengths check character by character

1

Anonymous

Feb 25, 2012

Just check if the two arrays have the same elements. If they do, then one has to be the anagram of another. If any of the characters do not match, then the arrays have different characters, and thus cannot be anagrams of each other.

Anonymous

Apr 7, 2012

@tijyojwad yes, we know the definition of a anagram. the test is to see if you can code it.

1