## Amazon Interview Questions

- 4of 4 votes

AnswersCar parking problem. An array given represents actual order of cars need to be parked. Like for example order is 4,6,5,1,7,3,2,empty. If cars are parked in some order like empty,1,2,3,7,6,4,2. Some person needs to get them into correct order, list out all instructions to the person to get in correct order with least number of swaps.

- hulk April 16, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 2 votes

Answersgiven a N x N matrix find the no. of times a word is present in that matrix. constraints you can move in 3 directions from one cell 1. forward , 2. down 3. diagonal . Find all teh occurance of all the word

- GOOGLE_SDE April 15, 2014 in United States

forward means right (x+1,y)

down mean (x,y+1)

diagonal means (x+1,y+1)

it can be done with BFS. {search the no. of occurance of a given word example "sachin" in the whole NxN matrix}

w | s | r | t | g | g|

a | a | c | h | i | n |

k | c | h | u | j | j |

o | h | i | n | y | q |

in this sachin can be found out 3 times.| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 1of 1 vote

AnswersGiven a huge file 100 million integers. He further divided the file into 100 files with 1 million integers in each and each file is sorted. Needed to find the k smallest integers.

- pulkit.mehra.001 April 07, 2014 in India

I used the concept of min-heap. Take the first element from each file and construct a min-heap. Take the root,as it is the smallest element and insert the next element from the file which contains the root root element. Heapify the tree and repeat k times.

The interviewer asked if another efficient method exists?| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 3of 3 votes

AnswersGiven a set of intervals like 5-10, 5-10, 8-12, 9-15

- blackfever April 03, 2014 in India

Find the ith smallest number in these intervals.

for eg:-

Suppose we have intervals like 5-10, 8-12.

Then total numbers in these two intervals would be: {5,6,7,8,8,9,9,10,10,11,12}

So, 1st smallest number: 5

4th smallest number: 8

5th smallest number: 8 (here is the

change since now we have duplicate elements also) and so on.| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 1of 1 vote

AnswersSliding window problem where window size is 3 and we need to find the minimum from the window.

- Vaibhavs April 02, 2014 in United States| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersGiven a list with duplicate values find the first unique elements in it.

- Vaibhavs April 02, 2014 in United States

for eg: BH BH F AL HJ AL HJ PK

so answer is F| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersGiven a matrix and need to traverse through it last position from first position and the matrix has 0 and 1 if there is 1 we cant proceed ahead.

- Vaibhavs April 02, 2014 in United States| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersCompare two release version and tell me which is larger

- Vaibhavs April 02, 2014 in United States

eg: 1.0.10 and 1.0.2

1.0.2 is greater

1.2.0 and 2.1.0

2.1.0 is greater| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersThere is a file which contains N words. There may be M anagrams in that file, K words on each anagrams. K>=1, M>=1, N>=1. You need to write an algorithm which will create one list for each anagram with k words and group all M lists with one data structure

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 1of 1 vote

AnswersFind your own method to balance an unbalanced binary tree.(you must not use existing methods like AVL, red black or b trees)

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersConvert a sorted integer Array to balanced binary search tree. This is very simple one and I could do it in O(n) time and O(1)extra space

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersGiven 2 sorted linked list , merge them into single sorted list. Change the pointers, don't copy data

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersGiven a read only linked list with next and random pointer , clone the list

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 1of 1 vote

AnswersIt was a design question. You have to design a game. it has different types of monsters and different weapons. hero would shoot monster. each monster would have some initial health. Each weapon would do some predefined damage to monster. when its health gets 0, monster would die/disappear. and there would be multiple levels. based on level, monster and their behavior would change.

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Object Oriented Design - 0of 0 votes

AnswersGiven 2 rectangles , find whether they are overlapping or not.

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - -1of 1 vote

Answersdelete all the nodes from a binary tree that lie on a path whose sum from root to leaf is less than a given value K. Twist was that the node values can be any integer. It may be a negative number.

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersData structure to push, pop and find min element in O(1) time.

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersGiven a linked list like a1-a2-a3-a4-b1-b2-b3-b4. Convert it into a1-b1-a2-b2-a3-b3-a4-b4

- suresh March 05, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersThere is a dictionary of billion words and there is one method provided

- pavan February 27, 2014 in India

String getWord(int index); We can give it index and it will return the String on that index .

Now word is given to us we have to find out its index. O(logn) solution was required.| Report Duplicate | Flag | PURGE

Amazon SDE1 String Manipulation - 0of 2 votes

AnswersFrog can jump 1 or 2 steps write the code to find out number of ways to go up to n steps

- pavan February 27, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Dynamic Programming - 0of 0 votes

Answersprogram to pruning a binary tree

- pavan February 27, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Data Structures - 0of 0 votes

AnswersYou are given an unsorted array of integers that contain duplicate numbers.

- Muhammad Adel February 20, 2014 in Luxembourg

Only one number is duplicated odd number of duplications, other numbers are repeated even number of duplications.

Find this number.| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersFind all nodes that are at a distance k from leaf nodes

- anon123 February 16, 2014 in United States| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersGiven a number N, find the smallest 3 digits number such that product of its digits is equal to N.For example for N=100 , 3 digits number is 455.

- sam February 14, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersGiven a function “f” in which 0 occurs with probability 0.4 and 1 occurs with probability 0.6. Using function “f” deduce a new function “f1” such that both 0 and 1 occurs with probability 0.5

- sam February 14, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Problem Solving - 1of 1 vote

AnswersYou are given a n-ary tree. print all the nodes bottom up except for the right most node at each level.

`1 2 3 4 a b c d e`

print all except 4 (right most at level 1) and e (right most at level 2)

- sukheshmg February 11, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersYou are given an unsorted integer array consisting of 1's and 0's. You need to rearrange the array with alternating groups of 0's and 1's. The group length is determined by the function f(x)

- sukheshmg February 11, 2014 in India

f(0) = 1

f(1) = 2

f(n) = [square of f(n-1) - square of f(n-2)]

if you run out of either 1's or 0's, then fill the array with whatever is left.

input: 0,0,1,0,1,1,1,0,0,1,0,0,1,1,0,0

output: 0, 1,1, 0,0,0, 1,1,1,1,1, 0,0,0,0,0

f(1) = 1

f(2) = 2

f(3) = sqr(f(2)) - sqr(f(1)) = 3

f(4) = sqr(f(3)) - sqr(f(2)) = 5

f(5) = sqr(f(4)) - sqr(f(3)) = 16

here we don't have enough 0's left to fill the last group. So, we add the five 0's that were left.| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - -1of 1 vote

AnswersHow to find the smallest number with just 0 and 7 which is divided by a given number?

- sunny.010203045 February 10, 2014 in India| Report Duplicate | Flag | PURGE

Amazon SDE1

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window