Amazon Interview Experience for SDE2
There were around 30 to 40 people in this round, all of us were given a question paper and sheets . There were three algorithm questions and we had to write syntactically correct code within an hour.Below are the question.
This was a face to face discussion focused on algorithm design .
- Given a map with roads, all roads in the map are straight lines . These road may intersect with each other at any angle . Calculate total distinct roads in the map . He was expecting to see how i represent the map as data structure, ask for questions on any ambiguity and devise an algorithm then code the solution on paper . I was able to give optimized solution on first try .Basically i used two dimensional array to represent the map . The array will have only 0’s or 1’s as elements . Continuous sequence of 1’s will represent a road.Do a depth first search on this array to find the total no of continuous 1’s.Tricky part was to determine roads in case we encounter an intersection.From intersection if we can move in same direction as the direction from which we came to the intersection we consider it as same road any road from the intersection to a different direction from which we came to intersection is considered as a different road.
- Print a matrix in spiral order. Syntactically correct code was expected on paper.
This was design round.This round went on for about an hour and a half.
- Asked about my current project, its design and architecture . Then asked me to draw the architecture of my project on white board and asked specific question on which component of the system did what and how they were implemented.
- Object oriented design of a parking lot . I gave a design and made use of Template method pattern, Strategy pattern and Abstract Factory pattern. Was asked counter question on my choices and their pros and cons . Be prepared for pros and cons questions on the choices that you make, and also gave me some changes in my design and asked whether it was a good idea or not . Then asked how this system would be deployed on parking lots .
This was again focused on algorithm design.
- Given a log file in the below format .
[19-10-2019:10:20:22] <some logs>
[19-10-2019:10:20:23] <some logs>
[19-10-2019:10:20:24] Memory usage = 10 MB
[19-10-2019:10:20:25] <some logs>
[19-10-2019:10:20:26] <some logs>
[19-10-2019:10:20:27] <some logs>
[19-10-2019:10:20:28] Memory usage = 18 MB
[19-10-2019:10:20:29] <some logs>
[19-10-2019:10:20:30] Memory usage = 22 MB
[19-10-2019:11:20:31] <some logs>
[19-10-2019:11:20:32] Memory usage = 10 MB
There are logs of memory usage present in the log file. As in above example the memory usage logs are 10, 18, 22, 10. Question was to find the maximum increase that has occurred in the memory usage . In the above example the maximum increase that has happened is 12 starting from 10 MB and ending at 22 MB
2. There are two source code repositories app01 and app02 which gets deployed at 7 PM in production every day . You are given below function to deploy the code from app01 and app02 in production up-to a given commit id.
boolean deploy(int commitId_app01, int commitId_app02)
if we call deploy(10, 12) then every commit from id 1 to 10 from app01 and every commit from 1 to 12 from app02 will be deployed in production and the function will return either true if deployment is successful or false if deployment failed .
A deployment is made (i.e deploy(n, m)) and deployment failed because of a faulty commit you need to write an algorithm to find the faulty commit using the deploy method in least number of deployments.
3. Given a set of integers find a subset with given sum. Subset Sum Problem
This was Hiring manager round . He first introduced himself and then explained the project that he is hiring for and other details about the company.
- Tell me something about yourself which is not there in your resume.
- Explain the architecture and design of your current project. Then asked counter questions on my project design and why we were doing things in one way and not the other . Also asked about the limitation and problems that are there in my project architecture and design and what can be done to solve those.
- Asked why we were using third party tool in my current project rather than developing one by ourselves.
- Asked about the recent work i did in my company(recently i worked on API gateway integration with rest services) .Asked what change would you have to make in order to expose web services and UI to public on internet . I explained about security issues that could arise on exposing to public and how we can handle that . Also explained about handling high traffic using API rate limiting and distributed rate limiting . Then asked how we can implement it .
- Asked if i had any questions.
Principle engineer round. Mainly focused on the design of work i have done till now and algorithm design.
- A brief intro about the interviewer his experience and the projects he has worked on.
- What is the toughest project you have ever worked on ? Why was it tough ? What did you do to solve the problem ? How did you design it? What choices you made and why?
- Gave me a single algorithm design problem and asked me to mail solution with all corner test cases to him in 30 mins. Find total number of turns in path between two node in a binary tree. You are given two node you need to find the path between these two nodes in binary tree and calculate the no of turns in the path . For example consider a binary tree where ‘a’ is the root node and ‘b’ and ‘c’ are left and right child of ‘a’, also ‘d’ is right child of b. The no of turns in path from ‘d’ to ‘c’ is 2 . The no of turns from b to c is 1 and no of turn from a to c is 0.
After few days i got a call from HR that i was selected, in few days they also sent me an offer which was more than what i was expecting .
- Its not just about solving the problem its about solving it quickly, so practice as much as you can.
- Its not just about solving the problem its how you approach the problem that is also very important. So think out loud . Let the interviewer know how you are approaching the problem. It will also help the interviewer in giving you hints.
- Always keep a lookout on the ambiguity in the problem statement and keep asking questions on that . The ambiguities are deliberately introduced in the question to check if you can find the ambiguity and ask clarification questions.
- Take the hints . Interviewers are always helpful and they will give you precise useful hints if you get stuck. It is important to catch the hint as fast as possible and proceed with the solution . if you are not able to catch the hint it is a big red flag.
- Never say that you cannot do it . Even if there is problem that you have not solved before or seems that you cant solve it, keep attacking the problem from different angles, interviewer will give you hints . But if you would say that you cant solve the problem it is a big red flag and you might end up getting rejected.
A big thanks to geeksforgeeks one stop shop for all interview preparation :).