Amazon Interview | Set 123 (On-Campus for Internship)
Online round: In this round there were 20 MCQ’s to solve and 2 coding question. Of the 20MCQ’s a couple of questions were on Quantitative aptitude, relationships, OS, DBMS, Data structures etc. there was negative marking for every wrong answer so I attempted only 15 for which I was sure.
Q2- given a binary tree where each node has some weight. You have to return the max weight in the binary tree.
Maxweight = value of root node + value in its left subtree and right subtree.
Ex - 2 / \ -1 3 Output = 4
1st round(50 mins):
Q1. Reverse link list in k chunks
Interviewer was first interested in approach then he asked me to code.
Q2. Spiral order traversal of binary tree
I first told him 2 stack approach but he asked me to do without stack .Then I gave him a solution using one queue and one stack and he finally asked me to code both the approaches.
Q3. Longest palindromic substring
I first used DP but he asked me to do O(1) space complexity. I was unable to do so.
2nd round :
Q1. Connect sibling pointer in a binary tree
Connect Nodes at Same Level
https://www.w3wiki.net/connect-nodes-at-same-level-with-o1-extra-space/
He asked me to do middle operation also and then he asked me to code 2nd problem.
https://www.w3wiki.net/design-a-stack-with-find-middle-operation/
Q3. Given n point in a 2d plane ,find k distant nodes from the origin.
I told him min heap approach and he was satisfied.
I used adjacency list representation, he asked me why
And finally asked me to code it.
Overall it was a very nice experience interviewing with them.
Some tips:
- Never give up
- Don’t start with coding ,first explain the approach.
- Be honest
- https://www.w3wiki.net/ – my guidebook.