Amazon Interview Experience for SDE-1 | Off-Campus 2021
Online Round: 2 Coding Question with Time Complexity Analysis
- Similar to nearest K coordinates from Origin. (Heap)
- Little bit of modification of 2-Sum, but I did in Brute Force way and it passed.
In the Last behavioural based MCQ Test.
After 5 days I got an email in which it mentioned that I will be having a quick connect with HR for Rounds Process.
- Quick Intro
- BST Iterator https://leetcode.com/problems/binary-search-tree-iterator/ (Medium)
- Basic Calculator https://leetcode.com/problems/basic-calculator/ (Hard)
- I Solved both but for last one my code was not 100% complete as we were running out of time but I gave the approach and final Time Complexity.
- Paint House https://www.lintcode.com/problem/515/?_from=[‘ladder’]&fromId=[’16’] (Premium on Leetcode, so attaching free Resource)
- BFS on Grid, The question was like you are given 2D Matrix with 0,1 and a starting coordinate from that you have to cover all 1’s and tell how much minimum time it will take to do that and if any 1 is left return -1.
Round 3(Behavioural, taken by SDM III):
- This Round was like brief Introduction, and that started with LP Questions
- A Deadline you missed.
- A Goal that you thought you will not be able to achieve but you did.
- A most Challenging Task you did.
- CS Fundamentals Questions, like difference between HTTP vs HTTPS, Thread vs Process, Memory Leak in Java, Classfull IP and its all Classes.
- After about a week I got an email that I am having my Last Round Next Week.
- A Small Introduction
- LP Questions
- 1 Coding Questions (Now for this I want to share that Interviewer itself was in doubt, the question was like you are given a Binary Tree with atmost 2 child and every child can have atmost 2 Parents, and you have to find a Maximum Path Sum from Root to Leaf)
- I asked what is the structure of that Node, So he said what you think. I wrote this:
- So he said Yes this is, (Now I was confused how come this can have links with Parent, maybe I am not able to get!)
Sample Test Case:
/ \ / \
4 5 6
- So, 1st Solution that I gave was normal dfs based that I try every path from root till every Leaf and in that method I take current_sum and one global_sum and update it accordingly.
csum, List<Integer> ds)
(csum > ans)
ans = csum;
finalAns = ds;
pubic List<Integer> solve(TreeNode root)
- Time Complexity: O(more than N) I was not able to figure out but it is I guess O(N^2)
- So, he told me to optimise it I told him that I will do something Post Order type Traversal and from left and right I will bring answer. But he told me that this will not work, So I was not able to find something better.
Conclusion: Be Confident in LP Questions, discuss Brute Force first.