Amazon phone screen interview experience SDE2

amazon logo
amazon
SDE II
April 17, 20252 reads

Summary

I had an Amazon phone screen for an SDE2 role, where I was asked behavioral (LPS) questions and a data structures & algorithms problem, ultimately resulting in a rejection.

Full Experience

Does interviewer decision can be biased?

I had an amazon phone screen and got rejection today I was asked three lps one was like you had an intitial deadline for delieverable now there is a new prior deadline and you are not able to deliver as expected how did you handle that situation. I answered it like with star format and explained the whole situation why they have modified the deadline and told that my manager assigned me this task. I will deliever minimum viable product with required features to complete it, since we don't want to ruin our relationship with customer. and have talked with customer to decided which features are essential to met the requiment and based on that Presented a poc and talked about actions that i perfomed and how we able to deliever that and customer was happy with the overall flow and outcome and we polished existing features and added remaining features in next sprint and added impact point as well and how this feature was integreated to our many products because of it's success Similarly answered 2 lps and I believe that I did good from my perspective

I was asked this problem and i explained the whole thought process how i would use hashmap and process the message insert it into hashmap as a key and expired time as value and had dry run the code with current example After all that interviewer asked can we optimize it i cannot think of optimization she gave me hint that may be you can try different data structure i thought of set and explained why set we cannot use for the problem. Later i thought of LRU cache with doubly linked list told that we can have two node one left and right right's previous will be most recent node and left we will have the least recent node we can check if the message has expired timestamp less then current time stamp then we can remove it from doubly linked list and hashmap everytime before we process a new message. Interviewer told me you can modify your existing code i add a Node class and add remove methods but time was running low since there were only 25 mins so she should told me add comments in the remaining functions.

/* Design a logger system that receives a stream of messages . message should only be printed at most once every 10 seconds Ci.e. a message printed at timestamp t will prevent other identical messages from being printed until timestamp t + 10) Input ["Logger", "shouldPrintMessage" "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage"] [[], [1, "foo"], [2, "bar"], [3, "foo"], [8, "bar"], [10, "foo"], [11, "foo"], [15, "foo"]] Output [null, true, true, false, false, false, true] */


Solution that i provided during interview and later modified it for lru cache implementation

class Logger:
def init(self):
self.messages = {}

def shouldPrintMessage(self, message: List):
timestamp = message[0]
msg = message[1]

if msg not in self.messages:
self.messages[msg] = timestamp + 10
return True
else:
if self.messages[msg] < timestamp:
self.messages[msg] = timestamp + 10
return True
return False

Interview Questions (2)

Q1
Handle Missed Deadline for Deliverable
Behavioral

You had an initial deadline for a deliverable. Now there is a new, prior deadline, and you are not able to deliver as expected. How did you handle that situation?

Q2
Design Logger System
Data Structures & AlgorithmsMedium

Design a logger system that receives a stream of messages. A message should only be printed at most once every 10 seconds (i.e., a message printed at timestamp t will prevent other identical messages from being printed until timestamp t + 10).

Input ["Logger", "shouldPrintMessage" "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage"] [[], [1, "foo"], [2, "bar"], [3, "foo"], [8, "bar"], [10, "foo"], [11, "foo"], [15, "foo"]] Output [null, true, true, false, false, false, true]

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!