I recently attended an interview with Amazon at WTC, Bangalore
Round 1 – Written (write code for any 2 out of 3)
1. Given an array of elements which is first increasing and then decreasing, find the maximum element in the array.
Points where based on how we handle the corner cases like what if we have only two elements in the array.
2. Given a string of parentheses, find if the expression is balanced or not ?
3. Given a binary tree, find the level which has maximum number of nodes, consider root as level zero
People were asked to write 2 or 3 lines about the approach they follow, the space and time complexity, data structures used to solve the problem
I attended 1 and 3 – scored 7/10, on my further analysis I had failed to handle the corner cases in question.3
Round 2 – Face to Face discussion
1. Write program to escape URL string, say you are given a URL string, you have to replace
“(space)” -> “%22”
“(double quotes)” -> “%d”
say http://www.google.com/hello world” -> http://www.google.com/hello%22world%5d
what is the space and time complexity, can we accomplish the solution with only one traversal of the string ?
2. Given a million of points(x,y) in a two-dimensional plane and a utility function to compute the distance from Origin, how will you return the smallest k distances from the Origin.
Answer : Use Comparator and sort the array, return first K elements from the sorted list
Follow up: why do we need to keep all elements in the sorted list, how can we maintain only k elements in the sorted list ? Time, space complexity of the solution. time complexity of the problem.
Round 3 – Face to Face discussion
3. Implement hash map of your own
1. How to handle a collision situation
2. How can we reduce the time complexity of rehashing process ??
Gave my best in this round but couldn’t clear it.
Amazon people were friendly all during the process.
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)
- Amazon Interview Experience | Set 242 (1 Year Experience)
- Amazon Interview Experience | 401 (3+Years Experience for SDE II)
- Amazon Interview Experience | Set 243 (2.5 Years Experience)
- Amazon Interview Experience | Set 391 (SDE-2, 5.5 years Experience)
- Amazon Interview Experience | Set 241 (1.5 years experience)
- Amazon Interview Experience | Set 248 (4.8 Yrs Experience for SDE II)
- Amazon Interview Experience (For Experience - 2.8 yrs) | SDE 1
- Amazon Interview Experience
- Amazon SDE II Interview Experience
- Amazon Interview Experience | Set 424 (For SDE 2)
- Amazon interview Experience | 411 (SDE-1)
- Amazon interview Experience | Set 412 (SDE II)
- Amazon Interview Experience | Set 343 (For SDE-1)
- Amazon Interview Experience SDE-1