Amazon Interview Experience for SDE | On-Campus 2019
Round1: Online Assessment Round
Online test was on mettyl platform: 28 Technical MCQ and 2 coding questions.Test duration was 90 mins.
Technical questions i remember were –
1. Implementing stack using 2 queues and given push should be o(1) and a series of push and pop operations. What are the number of enqueue and dequeue operations performed
2. int a = (b=6)+(c=8). What is the value of a?
3. There were some questions w.r.t. to operator precedence.
All are C and C++ related questions. If you know the basics of c and c++, you will be able to solve most of it.
1. Given a string with small letters convert the string into proper URL format considering the various constraints given. (like ru is always the domain extension and few other constraints)
i/p - ftpramgruindex o/p – ftp://ramg.ru/index
2. Given the 1D matrix of size k. Consider it as a 2D matrix of m rows and n columns(such that m*n=k) and return the sum of maxrow-sum and maximum-column sum.
i/p – [1, 2, 2, 3], 2 rows and 2 columns o/p – 10
The interview process consists of 4 technical interviews. Each technical interview is mainly based on Data structures and Algorithms. Code for an optimised solution to each problem asked in every round should be written on paper.
Tech Round 1: 50 mins
1. A glance at my projects and achievements.
2. A question quite similar to Minimum platforms
3. Given an array(size 365) of boolean values saying if a particular person is travelling on that day or not. The ticket schemes are given like for 1 day it costs Rs 2, for 7 days(continuous) it takes Rs 5 etc. We have to select the tickets in such a way that the total cost of all tickets is minimum for the whole travel. (somewhat similar to coin changing problem).
Tech Round 2: 90 mins
1. Reverse a LinkedList in the most efficient way. Can we reverse in 0(1) space complexity?
2. Check palindrome in a LinkedList say in 0(1) space complexity.
3. To find the maximum number of people in a party at any time given every person’s entry and exit time.
4. Given a 2D matrix containing 0 and 1 which are row-wise sorted, write the most efficient algorithm to return the maximum number of 1’s in a single row.
5. A question similar to this painters partition problem. He wanted a dynamic programming solution of O(k*N^2) time complexity.
6. Discussion on my project implementation.
Tech Round 3: 60 mins
1. A small discussion about my project database and backend implementation.
2. You will be getting a stream of edges for a directed graph. You have to tell at what point the cycle is formed. (My approach was using Disjoint sets ). He asked if I can implement the same algorithm to the undirected graph also? He asked me to implement Disjoint sets algorithm and to make it efficient using union by rank and path compression. We discussed its time complexities.
3. Asked me about Ford-Fulkerson max flow algorithm. We discussed the applications, space and time complexities of the algorithm.
4. There is a codeword to win the game and an input stream of characters is coming. When the input stream forms a codeword, the player wins. Find at what point a player wins. Basically it was substring search problem. I told my approach using Z algorithm and later we discussed the KMP algorithm.
5. Some simple questions on OS like semaphores, threads, scheduling etc.
Tech Round 4: 60 mins
1. He was checking on my skills written in Resume. Later he asked questions on my blockchain project.
2. Write code for recursive soln of DFS for an N-ary tree
3. Write code for iterative soln of DFS for an N-ary tree.
4. Write code for iterative soln of DFS for an N-ary tree without a stack.
5. Write code for iterative soln of DFS for an N-ary tree without stack when parent pointer is given.
After listening to the question clarify any doubts you have, else you might end up solving a wrong question and this will leave a bad impression on the interviewer. Even if you know the solution, first tell the brute force and then optimize it. Write the code once you reached the optimised algorithm. Discuss with the interviewer, about tradeoffs between space and time complexities. Don’t panic if you take more time to solve a problem, they expect you to do so. Don’t panic if you can’t come up with an optimised solution rather interact with the interviewer about your approach so that he may point where you are going wrong. Tell them your thought process instead of telling the solution straightforwardly. Amazon puts more emphasis on implementing optimised data structures rather than just coming up with a solution. So make sure that your data structure implementations are in optimised form. Stay confident and trust your instincts.