Experience: 4+ years in Product based company.
Applied through amazon career portal.
After one week received OA link.
Online Assessment:
Section 1: (90 mins)
Section 2 & 3: Based on behavioural and situation-based questions.
Received a call from HR after 1 week. Round 1 & 2 got scheduled after 3 weeks.
One month gap between OA and Round 1.
Round 1: Technical (LLD)
Interviewer: Sr. SDE (very supportive and encouraging)
Started with two amazon LP questions. I followed STAR based approach. But interviewer not satisfied with my answers. You must remember the task in depth. They will dig deep into it. (20 mins)
Design Email domain server (LLD). Firstly, I didn’t understand the question properly. Interviewer explained it one more time. I never seen this question before. I was not able to think about the solution. Interviewer gave lot of hints he also suggested some APIs which are needed. Because of lack of preparation, I couldn’t solve it fully. Solved it partially. He also breakdown the problem into two parts. First part, to do domain name registration and second part email creation, sending email between same domain users and different domain users and handling privacy.(35 mins)
Expectation from Interviewer: I need to come up with high level design with DB selections and other components details. later deep dive into APIs and schemas and indexing and scalability.
Example: user must be able to register their domain. Example leetcode.com.
owner can create emails like xyz@leetcode.com
sending mail between same domain and different domains like leetcode.com & codeforce.com
Learnings:
Round 2: Technical (DSA)
Interviewer: Sr. SDE
Started with one Tree based question (35 mins) and two amazon LP questions (20 mins).
Given two nodes of a binary tree. Find the distance between two nodes in a tree with unique values.
Tree with pointers from child to parent.
TreeNode{
int val;
TreeNode parent;
} 1
/ \
5 3
/ \ \
4 8 7
Ex: distance(5, 7) output: 3
Distance(8,7) output: 4
Distance(4,8) output: 2
My solution:
First Approach: Iterating from node1 to root with storing distance to each node in the path using hashmap. iterating from node2 to root also checking current node exist in the map if it exists then I am returning current Distance + value from map.
Interviewer told me to not use the map. So, I came up with set-based solution.
Second Approach: First, I will add all the nodes into set which are in the path from node1 to root. second, i will iterate from node 2. using set i can find lowest common ancestor (LCA) from node2. paralally, i can calculate distance from node2 to LCA. Again, iterate from node1 to LCA to find dist from node1 to LCA.
Return total distance.
Time & space complexity is O(h). h is height of tree.
I have coded for both approaches.
Edit: it is possible to solve in O(1) space. sea the solution section of https://leetcode.com/problems/intersection-of-two-linked-lists/description/
I think interviewer wanted to ask one more question. But, explaining both the approaches took 32 mins. So, Interviewer just asked me what are all edge cases I am thinking. I explained all the edge cases.
Later two Amazon LP questions for 20 mins. able to answer with STAR.