Amazon Interview | Set 9 (Answers)
Last Updated :
05 Aug, 2024
This post is about answers to the questions asked in
Amazon Interview | Set 9. It contains links to some of the solutions available on the geeksforgeeks. I have also written my answers which I replied in the interview. I hope it would help the readers.
Online Programming Round: (5 methods, 2 hours)
3) k-th smallest element in BST
5) Longest Increasing Subsequence
Telephonic Interview 1:
1) Row with max 1s
2) Anagram
3) Rotate and delete
Telephonic Interview 2:
3) Find the distance of every other point from P. Then use of max-heap of size K.
Face-to-face Interview 1: (Hyderabad, Date: November 08, 2012)
2) I gave the following solution (with the help of the interviewer):
1. For every set, find out the number of sets it has intersection with. Also maintain those set indices.
2. Remove the set which has maximum number of intersection. And update the remaining numbers.
3. Repeat step 2 till we have any set which has intersection with any other set. At the end, we will have the solution. (Still not sure about optimality).
We can relate the solution with graphs: Remove some nodes so that remaining all the nodes are isolated nodes.
Searching: To make searching efficient, we can build trie data structure using bits for every set. So that we can find the intersections fasters.
Face-to-face Interview 2 (with a manager):
1) I tried for some time. Then the interviewer gave me the formula. The number is 1+ceil((N-W)/S) in all the cases.
For second part of question, simple solution is to find min in every window. But we can optimize so that we can utilize previous results/previous min.
Bit optimal: I created a min-heap of W elements. But the heap contained indices of the array elements, not the values inside the array itself. The indices were stored in heap as per their values in the array. Then for a new window, search the heap linearly (heap was in form of array), replace the old indices (which are no longer in the new window) with the new indices, and adjust that index in the heap. After adjusting all the new indices, we will have new min for the new window at the root. (Not sure whether the complexity brought in to the solution is worth!)
Face-to-face Interview 3:
2) I gave a solution based on trie data structure using characters of the string. But he suggested to build trie based on the string itself. However, I was not able to think in that way.
3) Linear search. Binary search.
Face-to-face Interview 4 (with the manager of the unit of opening):
2) I said, we can organize an online coding competition. People would register and we will have the details. He replied, it’s too expensive. Then I said, we can postpone the competition!
All the Best!
Thanks to
Hitesh for sharing his answers.
Similar Reads
Amazon Interview | Set 93 I have just completed a full interview with Amazon and wanted to give back to GeeksForGeeks my experience because it has helped me so so much to go through it. 1st phone interview Why Amazon? How do you find out the cause of a slow UI request? Write function to convert a stream of incoming character
1 min read
Amazon Interview | Set 29 I am very much excited for sharing my experience for Amazon, I went through 6 rounds and really enjoyed a lot for facing all of them and i feels like in each round that GEEKSFORGEEKS is the one the best site which gave me lot of ideas for solving the problems, This is THE BEST site for coding for ge
5 min read
Amazon Interview | Set 5 I've attended the Amazon interview in Hyderabad, This was kindle team, I got rejected but I'd like to share the experience, thought of giving back something to geeksforgeeks, which was a great reference for me. Written test Very straight forward 1. Given a linked list, sort without extra space. I wr
2 min read
Amazon Interview | Set 13 Round 1 (Telephonic) Q1. For a given number, find the next greatest number which is just greater than previous one and made up of same digits. Q2. Find immediate ancestor of a given Node Q3. Clone the linked list having an extra random pointer in nodes which is pointing random node in the list. Roun
2 min read
Amazon Interview | Set 74 Phone Interview: 1) Given a 2D matrix where every row is sorted, give the index of row which has maximum number of oneâs 2) Given a Binary tree, print its every level in a new line. Face to Face Interview (Round 1): 1) you have an array which has a set of positive and negative numbers, print all the
1 min read
Amazon Interview Questions and Answers Getting an interview with Amazon is a big achievement, but it can also be a bit challenging. Founded by Jeff Bezos in 1994, since its start as a small online bookstore in 1994, Amazon has grown into a global leader in e-commerce, cloud computing, and AI. Known for its focus on customers and constant
6 min read