Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

"you have unsorted array[n] elements. the numbers in the array[n] occurs event times except one number occurs odd time. So, write an algorithm to find that number. Also explain its complexity too. (time and space) both. (On ALGORITHM)"

Sort and XOR the elements the even elements will cancel out.

- Anonymous August 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why do you need to sort it?

- ACP Pradyuman September 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

use the last name of the person..

read abt various techniques to avoid collisions..

for such a question u will have to answer with pros and cons..

- r August 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

3. you have html page directory. in each html page u have written name and phone number. now you have to make normal directory from that information. write an algorithm that convert html directory to normal directory.
how can we do this??

- rash August 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For Q3 i am not getting the question

- anshulzunke September 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

please can you elaborate the question? what do you mean by directory here??

- anonymous October 01, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Q2-Ans : Read each element from array and put it in an Hash-table as key-value pairs(key - number, value- no.of times it occurred). Then read the hash-table values and divide each value by 2. which value gets a remainder 1 that is the number which occurred odd time in an array.

- Nagesh January 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

html directory means html files container. Then what is mean by normal directory, what it contains text files or MSoffice files.

- Nagesh January 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Q3 : html directory means html files container. Then what is mean by normal directory, what it contains text files or MSoffice files.

- Nagesh January 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

read the array and put the elements in a HashSet.As u keep reading the array, do get for every element and if found ,remove it.Ultimately the only element which is there odd many times will be the item left in hasSet.Reason to use hashSet is the lookup wld be O(1).

- priyank.mundra January 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

"you have unsorted array[n] elements. the numbers in the array[n] occurs event times except one number occurs odd time. So, write an algorithm to find that number. Also explain its complexity too. (time and space) both. (On ALGORITHM)"

You can do it in O(n). The idea is that if you multiply the numbers and divide when it is divisible by the current element, at the end, all even numbers will cancel out, leaving the odd number only:

int number = 1;

For each element i in the array:

if number is divisible by i [i.e. if( number mod (a[i] == 0) ]
then number = number / a[i];
else number = number * a[i];

return number;

- mayra April 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Forgot to mention: Time complexity: O(n), Space complexity O(1)

- mayra April 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if array is too large.. then it can cross the limit in multiplying.

- kak January 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void findodd(int [] ary){
Multimap <int,int>map=new multimap<int,int>();
for(int i=0;i<ary.size();i++){
map.put(a[i],a[i]);
}
for(inti=0;i<ary.size();i++){
Collection<int> list=map.get(a[i]);
if(list.size()%2!=0){
system.out.println("here is the odd one"+list.get(a[i]));
}
}
}

- pradeep January 10, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More