# Amazon Interview Experience | SDE-1

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

Amazon visited NIT Jalandhar on 16 Aug, and 5 were hired. Note: in each round, I was asked to write code on paper for every ques.

Online Coding test:
1) Given a string of form a+b=c where one among a.b.c is replaced by x. find x.
2) A=1, B=2, C=3…Z=26. Find possible decoding of the given digits sequence.

Count Possible Decodings of a given Digit Sequence

28 MCQS

Round 1:
1) Collect maximum gold coins from potholes without selecting adjacent potholes.

Maximum sum such that no two elements are adjacent

2) Given a number n. Print all numbers from 0 to n which have adjacent digits as the abs diff of 1.
(Stepping numbers)

Stepping Numbers

Round 2:
1) Minimize the transactions needed to balance money between friends. Per transaction may not
be equally distributed among all i.e. it is possible only few people are involved in that
transaction not all. (More like Simplify debts of splitwise app)
2) Min and Max heap. With diagrams and proper illustration of extracting and inserting.
3) Heapify the min heap
4) Insertion in min heap

Round 3:
1) N-ary tree. Create its mirror tree
2) N-ary tree with all positive keys. Find maximum sum path in whole tree. (If you think correctly it
will start from some leaf node and will end at other leaf node since all keys are positive)
3) Producer consumer problem discussion. Semaphore, mutex, wait and signal. Then told me to
write code for it using wait() and signal() for both producer and consumer (General code not in
cpp or java)
4) Discussion over distributed systems. N-producers N-consumer problem in distributed systems.
No. of mutex variables required to solve N-producers N-consumer problem? (ans: 1)

Round 4:
1) Project Discussion (20 mins)
2) Singleton class. Its uses. Real world practical use. How to make a class singleton class. Code it.
3) Set right siblings of nodes. I told level order traversal. But he insisted for optimization. Told him
O(1) space complexity sol, He was satisfied.

Connect nodes at same level using constant extra space

4) Length of longest palindrome substring.

Longest Palindromic Substring | Set 2

Tips to crack Amazon Interview:
1) Do first 200-300 Leetcode coding questions. https://leetcode.com/problemset/all/
2) Do all Amazon most asked questions from geeksforgeeks and do puzzles also. Sometimes they ask.

Amazon topics for Interview Preparation

3) 300 java ques from javaTpoint .
https://www.javatpoint.com/corejava-interview-questions