## Amazon Interview Question for Software Engineer / Developers

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

got selected by the way :)

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

were the results announced the same day?

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

--

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

no, after 2-3 days

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

did u answer all questions correctly???

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

Given a matrix of characters M and an input string S, find if S occurs in M in horizontal or vertical direction.

Any thoughts on this questions .

I think i should search the first char of string S in matrix which will take O(M*M) time then i think we can proceed in horizontal or vertical direction. I know this is very basic solution and interviewer is probably expecting better than this .

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

My approach towards this problem is
Lets say we have matrix of M having m rows and n columns
always search row wise for S or S[x-1] where x is the length of string.
Now suppose currently you are at (i,j) position in matrix.
int a =0; // a global variable
if( M[i,j]== S && i<=(m-x)){

bool flag = true;
for( a = 1 to x-1){
if( S[a] == M[i+a,j])
continue;
else{
flag = false;
break;
}
}
a= 0;
if(flag){
we got the string.
return ;
}
}
if( M[i,j]== S && j<=(n-x)){

bool flag = true;
for( a = 1 to x-1){
if( S[a] == M[i,j+a])
continue;
else{
flag = false;
break;
}
}
if(flag){
we got the string.
return ;
}
}

if( M[i,j]== S[x-1] && i<=(m-x)){

bool flag = true;
for( a = 1 to x-1){
if( S[x-a] == M[i+a,j])
continue;
else{
flag = false;
break;
}
}
a = 0;
if(flag){
we got the string.
return ;
}
}
if( M[i,j]== S[x-1] && j<=(n-x)){

bool flag = true;
for( a = 1 to x-1){
if( S[x-a] == M[i,j+a])
continue;
else{
flag = false;
break;
}
}
if(flag){
we got the string.
return ;
}
}

//If none of the above returns then
//Start searching from S[i,j+ a+1] if a+1 <=n
// else start from S[i+1,0]

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

Are you telling me they asked you only coding questions ?

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

Not only coding but all were related to algorithms , design and coding.

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

What' the answer to the linked list question (2) and the stock question (3)?

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

In list question. make one scan on list 1 and one scan on list 2. Let sizes be m and n. If m is larger then n, then skip pointer of m from head (m-n) times. now size of both list is same. now skip each pointer side by side, till you reach common node.

in stock question one option in brute force method O(n*2). Another way is to keep track of current max and try to find minimum after that. if you find max again. reset every thing and remember the last max loss.

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

Can you eloborate more on the stock solution please? What exactly does the question mean and what's the solution in detail.

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

Congratulations, AnonymousUser

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

Thanks

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

How do you answer the Round 5 questions?

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

Given an array of integers from 1 to N, and given a number X, how many ways are there to pick X elements from the array such that no two elements in the selected X elements are consecutive.

for any k : k*(k-2)*(k-4)* (k-6) till zero......

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.

### 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.