Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Amazon Interview Experience for SDE-I

  • Difficulty Level : Medium
  • Last Updated : 19 Aug, 2019


Online coding test:

Three coding question were there on the hackerearth platform. It’s 70 minutes test.

1) Find next greater number with same set of digits. If next greater element does not exist print “-1”.

Input: n=327698

output: 327869

2) Given array of  elements with zero and one only, you can do following operation at-most one time.

operation: flip all elements from i to j index where i<=j.

Now you need to print maximum number of one in array after doing these operation.



1 0 0 1 0 0

Output: 5

3) Given array and integer k you need to tell that whether array can be sorted or not after following operation any number of times.

operation: you can swap (i) index element with (i+k) index element any number of times.

Print the sorted array if the array can be sorted by doing the above operation or print “-1”.


n=8 k=2

1 2 7 8 3 4 5 6


1 2 3 4 5 6 7 8


n=8 k=2

1 4 5 6 7 8 2 3

Output2: -1


Round 1:

1) Tell me about your self.

2) Given binary tree, complete path is defined as root to leaf. The sum of all nodes on that path is defined as sum of that path. Given number K you need to remove the nodes in binary tree which don’t lie in any path with sum>=K.

The function was given with root of binary tree and K you need to return the root after removing the nodes which don’t lie in any path with sum>=K.






3) Given rotated sorted array find the minimum element in the array.



7 8 1 2 3 4 5 6

Output: 1


Round 2 (Managerial round over video call):

1) Tell me about yourself.

2) Current role in the company.

3) Project you liked the most worked in the corporate life.

4) Time when you are given task and you are not able to complete on your own and take help of other colleague.

5) Time when you have received  critical feedback from your manager and how did you improve it?

6) Extra work you have done in the previous company apart from your regular work.

7) Which was the most critical task in your work in previous company and how did you manage that?


Round 3:

1) Tell me about yourself.

2) Stream of customer ID and product ID are arriving continuously. Now there will be query at any moment of time. You need to answer the query.

Query: Given product ID, number of the product with this product ID sold to customer.


Current Entry:

pID      cID

1          499

3          421

1          645

1          989

2          424

Query: pID=1

Output: 3

How will you space optimised this problem?

3) Number is arriving in the stream and the fixed K is given in the starting of Input. The below query can be asked at any moment of time. You need to answer the query.

Query: find K th maximum element in current stream.



Current Stream: 8 7 1 2 4 5 9

Output at the moment: 7

4) In the binary tree leaf’s left and right node will not be null. one leaf’s right node will be connected to node which is next leaf in the in order traversal. and the leaf’s left node will be connected to previous leaf according to in order. First leaf’s left will be the last leaf in the in order traversal and last leaf’s right node is connected to first leaf in the in order traversal.

You need to print in order traversal.

Expected Time Complexity: O(n)

Expected Space Complexity: O(1)




4 2 6 5 7 1 8 3 9 10

5) Write the optimised code for LRU Cache.

Size of LRU cache will be given in the input.

6) What is polymorphism?


Round 4 (Bar Raiser round over video call):

1) Tell me about yourself.

2) Check If one BST is subtree of another BST.

Function will be given with root1 and root2 as parameter of BST-1 and BST-2 and will return true if second BST is subtree of first BST or return false.

Note: Elements can be repeated. BST was created with all less or equal element will go to left child of node and greater element will be on the right child of the node.



Output: true.


Result: Hired!!

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!