Amazon | SDE2 | Jun 2020 [Reject]

Round 1:
GIven a relationship of heights of persons in list return true if all relationships are valid else false.
for eg:
Input :
[[Alex,Bella],[Bella,Alexendra],[Alexendra,David]]
Means :

  1. height of Alex > height of Bella
  2. height of Bella > height of Claria
    so on ...
    Output:
    true

Input:
[[Alex, Bella], [Bella,Alexendra],[Alexendra,Alex]]
Output:
false
as height of Alex cannot be more than Bella but less the Alexendra.

My approach was Dfs with each name as node in graph and if cycle exists return false.
(I think this approach got me rejected in interview.The interviwer was asking me to use some other data structure but my mind got stuck with this ...)

  1. Given a number find if it's prefect square or not.
    Simple O(log(number))

Round 2:

  1. Smart Grocery Basket
    Every user orders 'k' items in each order. And you have the last 'n' orders of a given user as input.
    You have to create a Smart Basket/Cart for the user.
    Smart Basket contains the all commons items for each user which they have ordered in last n order.

This is open ended question don't assume anything keeping asking for more info from interview and then try to solve it.

  1. You have an array of size 'n'. the array has integers. There is a moving window of size 'k'. For all the possible windows,
    print the first negative number.
    Hint use: I solved it using LinkedList to keep track of next -ve number in the array while sliding the window which allowed me to add new element i.e -ve element in linked list in O(1) using tail pointer and removing any -ve element while sliding window using head pointor O(1).

Round 3:

System design --
Low level and high level design of chess game.
(I already had done the same quesiton 2 days back so nailed it).

Bahviours and previous work experience question:
Interviwer was asking me quesiton related to my current project.
Tips: Just listen to thier question and try to mix your answer with amazon 14 principles.

Comments (4)