Amazon Interview Question for Software Engineer in Tests






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

sort the first array with nlgn
then just using binary search find the 2nd array element in the first array

- geeks July 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Stick on in a hash table, search with the other. O(n).

- memo July 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

using hashtable will give the complexity of O(m+n).
If we sort the smaller array (m<n) then we can get the complexity to O(nmlogm)

- Anonymous July 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

O(nmlogm) complexity is preferred of there are a lot of numbers.

- Anonymous July 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I dont think so - O(nmlogm) will always be bigger than O(n+m) for large n and m

- Anonymous July 29, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

consider
m > base of logarithm (which i believe usually considered 2)
=> log m > 1
=> mnlogm > mn

and m > 2 (for me)
=> mn > 2n
=> mn > 2n > (m+n)
=> mnlogn > mn > 2n > (m+n).

- BiologicalDaddy August 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

i am sorry. ignore the comments. I was comparing 7n.

- Anonymous July 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If we sort the smaller array (m<n) then we can get the complexity to O(nlogm).

- Raquibur July 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorting smaller array of size m is of complexity O(mlogm) in itself. The overall complexity will become: O( nlogm + mlogm)

- Anonymous July 29, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can solve it using counting sort concept only creating counting array after merging the 2 array

- akhilesh August 04, 2011 | 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