Skip to content
Related Articles

Related Articles

Improve Article

Amazon Interview Experience for SDE-1 (Off-Campus)

  • Difficulty Level : Medium
  • Last Updated : 11 May, 2021

I appeared for the amazon’s interview for SDE full-time role, and here is my experience

Technical Interview Round-1

  1. First question was there are given n ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to the sum of their lengths. We need to connect the ropes at a minimum cost.

    For example, if we are given 4 ropes of lengths 8, 5, 1, and 2. We can connect the ropes in the following ways.

    • First, connect ropes of lengths 1 and 2. Now we have three ropes of lengths 3(1+2), 5, and 8.
    • Now connect ropes of lengths 3 and 5. Now we have two ropes of lengths 8(5+3) and 8.
    • Finally connect the two ropes 8+8 and all ropes have connected.

    Total cost for connecting all ropes is 3+8+16 = 27.

    I told him solution using a priority queue, and also we can implement using the minimum heap, so he asked me to write code by implementing the whole heap function then he asked me about the time complexity of code, all the function of heap, why the time complexity of heap is log(n) and to explain them each and every function of code. I was able to write the code and to explain the time complexity but he was asking why the time complexity of insertion, deletion is log(n), I told him because the maximum height of heap will be log(n) ( where n is the size of the heap) and each level will have a count of element double then next so first level will have 1 element then next atmost 2 then 4 like this so last element will have 2^h element



    in this way, maximum height will be log(n) but he did not seem to be satisfied, and maybe I was not getting his question so he told me we will move to the next question then later we will discuss this.

  2. Next question was robber is planning to rob houses and all houses are connected in form of a tree. Each house has a certain amount of money stashed, the only constraint stopping the robber from robbing each of them is that connected houses have security systems connected and it will automatically contact the police if two connected houses were robbed. you have to find the maximum amount of money robber can collect without calling the police

    I was thinking solution, and also I was discussing my solution with the interviewer I was going off track, but the interviewer was helpful he gave me test cases where my logic will fail and gave me some hint, so I come up with a recursive solution, and he was also satisfied with the solution. He asked me about the time and space complexity.

Technical Interview Round-2

  1. Discussion on the project.
  2. Then He asked me coding question Given a binary tree, a target node in the binary tree, and an integer value k, print all the nodes that are at distance k from the given target node. No parent pointers are available.×258.png
    Consider the tree shown in diagram
    Input: target = pointer to node with data 8.  
    root = pointer to node with data 20.  
    k = 2.  
    Output : 10 14 22
    If target is 14 and k is 3, then output  
    should be “4 20”

    I told him the logic O(n) solution.

  3. Then a discussion on internship project why using this method only and so on.
  4. You have given a list of songs, and you have to play songs randomly how will you implement them.

    I told him I will use a random function to find a random number then mod it with the size of the list to find an index from 0 to size then I will play the song corresponding to that index.

    Then he told me that songs should not repeat then I told him to move the current song to the end of the list and then I will decrease the size so that we will not consider the last element we can use vectors for this.

Technical Interview Round-3

  1. It was both technical and behavioral round
  2. Have You Faced Any Tight Deadline How Did You Handled It
  3. Any difficult situation
  4. How Do You Handle Conflict in the Workplace (with team or manager)
  5. The time when you received negative feedback from your manager
  6. Tell me about the biggest risk you have taken
  7. Given the structure of the train, and given arrival and departure time of the train and initially, each train will have green color now if two train overlap color will change to blue to implement the function. variation of this problem

    Structure of train


    struct train
    string color;
    int arrival_time;
    int departure_time;

    First I told him the basic O(n^2) solution then I told him O(n) solution and he asked me to write the code for O(n) solution.


  • Keep asking for the clarifications of question and edge cases.
  • Try to discuss your approach with the interviewer and think out loud, The interviewer is there to help you out.
  • Keep track of all edged cases and ask your interviewer about them.
  • if the interviewer is not able to understand your approach try to explain with help of pseudo code.
  • Don’t make your own assumptions, tell them that you are making these assumptions, and if they are good with that then only proceed with your solution.
  • Hope this helps, Best of Luck…….

Verdict: Selected!

Thanks, GeeksforGeeks for helping me throughout my preparation journey, I did my complete preparation from GeeksforGeeks.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.

My Personal Notes arrow_drop_up
Recommended Articles
Page :