I had my SDE New Grad interview yesterday at amazon and very different than what I had planned for.
I went in after completing the entire amazon explore card on leetcode and preparing for some behavioral questions and leadership principles, but the interview had nothing to do with DSA.
Q. Design an API, which takes in a phrase from alexa device and rules from the user and outputs whether that phrase follows those rules or not.
bool validatePhrase(string phrase, vector<rule> rules)
Phrase:
"Alexa! switch on the bedroom lights"
Rules:
1. The first word of the phrase should be alexa
2. The second word of the phrase should be a verb
3. The length of the phrase should not be more than 30 words.This was really wierd since I had not heard of anyone getting design questions in the new grad role interview. After some initial discussion and clarifying my doubts, he said that a rule can be anything and user can define his own rule which your API has to validate. After that, things got complicated.
Q. Design a cache to store the latest value of a key.
Follow up:
store the timestamp as well with the key and keep a list of values for a single key
Follow up:
Given a timestamp and key, return the value nearest to the timestamp.
Follow up:
What would happen if timestamps do not come in increasing order
Q. Given 2 helper APIs, make an algorithm which can make product suggestions for a user. Sugestions should be based on the products which the user has not bought but his friends have.
// API 1 --> returns friends of a person
List<Person> getFriends(Person person)
//API 2 --> returns products which a person had bought
List<Product> getProducts(Person person)Follow up:
Return the suggestion in decreasing order of frequency
Follow up:
Return the suggestions based on the dfs algorithm i.e. obtain suggestions not only from friends but from friends of friends of friends and so on... until the leaf node.
Behavioral Questions were pretty standard -->
Tell me about a time where you had to make an Independent decision. What did you manager think about it.
Tell me about a time when you had to overcome a challenge
Tell me about a time when you missed the deadline
Tell me about a time where you had to make a quick decision without much information
Tell me about a time when you had to cut corners or you did not consider all available options because you were working close to the deadline
Tell me about a time when you faced difficulties in a project and did not had enough information to start with and how did you approach that problem and what was the outcome.
Hope this helps!!