# Amazon Interview Questions – Set 12

Company : Amazon
Campus : NIT Trichi
Interview Type : Campus Placement
Eligibility criteria : >= 8 pointer out of 10

Round 1 (Written Test):

20 objective(c+os+dbms+networking) + 2 coding question

Question 1:

Generate the following pattern when x is given upto Nth terms

For ex:

Input: x=2 ,N=5

OUTPUT:

2

12

1112

3112

132112

Question 2:

Find the next higher no. Of x Whose binary represent does not contain consecutive 1s-

For ex:

Input:

12

Output:

16

Round 2:

3 coding question+project discussion:

Q1. Write a C program that, given an array A[] of n numbers and another number x, determines whether
or not there exist two elements in S whose sum is exactly x.

Q2. Write an efficient program for printing k largest elements in an array. Elements in array can be in any
order.

Q3. Given an unsorted array in which every adjacent element is differ by either +1 or -1
Write an efficient code to find x where x is also given.

Round 3:

1 Question(tree)+project discussion.

Find the lowest common ancestor of given n nodes in given binary tree. Nodes are given in array of size n.

expected time complexity : O(n)
space complexity :O(1)

Round 4:

Project discussion

Coding Question: find nth node from the end of linked list.

Round 5:

Q1. Implement LRU cache where searching complexity will be O(1)?

Q2. What is multithreading ,apply it on the implemented cache,

Q3. What is critical section relate it with this code?How to solve the problem of critical section.

Q4. Difference between semaphore and mutex?

Q5. Project Discussion.

### 4 Thoughts on “Amazon Interview Questions – Set 12”

1. MARI MUNEESWARAN M on November 7, 2015 at 11:06 am said:

This will helpful for me in future.
Thanks.

2. JANANI SANJEVI on December 12, 2015 at 10:34 am said:

These questions are very useful to attend the interview.
Thanks.

3. pradeep kumar on January 6, 2016 at 11:44 am said:

Input: x=2 ,N=5

OUTPUT:

2

12

1112

3112

132112

• Phanindra on January 7, 2016 at 8:13 pm said:

Input is 2.
-> It contains one 2 i.e “one” “two” i.e 12
-> Now do the same for latest one(12)
in 12 , we have one 1 one two i.e 1112
->repeat the same for 1112
in 1112 , we have “three” 1 and one “two” i.e 3112
->repeat the same for 3112
we will have
132112