Amazon Interview Question for Software Engineer in Tests






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

divide and conquer?

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

Try searching from the top right corner...

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

Performing Binary Search on an sorted array would be the most efficient one...

- Jayanthan May 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if we use the binary search then mid index we can use for row or col index of MxN matrix....?
please little bit elaborate

- Career September 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Simple quaternary search should help, and you would get the answer in O(logN) time.

- SAN May 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In case of a[m][n] matrix.
column = n; // start from last column.
row = 0; // start from first row.
while(row > n and column > 0)
{
if(a[i][j] == searchValue)
{
print row and column
return;
}
if (a[i][j] < searchValue)
{
//increase the row only.
}
else
{
// a[i][j] > searchValue
//decrease the column only.
}
}

- sindhu May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Divide the matrix in four n/2 x n/2 matrices:
A B
C D

if n = 1, compare and print if equal
If n >= top left of A and n <= bottom right of A, search in A
if n >= top left of C and n <= bottom right of C, search in C
if n >= top left of B and n <= bottom right of B, search in B
else if n > bottom right of D exit
else search in D

- Ashish Kaila June 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Linear Step searching algorithm for this.
Start at the top right of the matrix.
If top right element is > target element then move left.
or else move down.
Keep doing this until we find the target.
Average case is O(n). If the element is at the bottom left then there are 2n steps

- Anonymous February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

Use Linear Step searching algorithm for this.
Start at the top right of the matrix.
If top right element is > target element then move left.
or else move down.
Keep doing this until we find the target.
Average case is O(n). If the element is at the bottom left then there are 2n steps

- ViggyHopeless February 26, 2012 | 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