Amazon interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Amazon
upvote
share-icon
3 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: Data structures, Algorithms, Dynamic Programming, Recursion, Trees, DBMS.
Tip
Tip

Tip 1 : Kindly prepare basics of data structures properly.
Tip 2 : Always have an answer ready for some questions on your projects.
Tip 3 : Always have basic knowledge of the tech stack being used.

Application process
Where: Campus
Eligibility: No criteria
Resume Tip
Resume tip

Tip 1 : Always have your resume well structured
Tip 2 : Use max 2 fonts for headings and details.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 Minutes
Interview date2 Jun 2022
Coding problem2

The round was 11 in the morning. It had 2 medium questions and some mcq related to leadership principles.

1. Rotting Oranges

Moderate
20m average time
78% success
0/80
Asked in companies
Samsung R&D InstituteSalesforceSamsung

You have been given a grid containing some oranges. Each cell of this grid has one of the three integers values:

  • Value 0 - representing an empty cell.
  • Value 1 - representing a fresh orange.
  • Value 2 - representing a rotten orange.
  • Every second, any fresh orange that is adjacent(4-directionally) to a rotten orange becomes rotten.

    Your task is to find out the minimum time after which no cell has a fresh orange. If it's impossible to rot all the fresh oranges then print -1.

    Note:
    1. The grid has 0-based indexing.
    2. A rotten orange can affect the adjacent oranges 4 directionally i.e. Up, Down, Left, Right.
    
    Problem approach

    Firstly i used naive approach ie Traverse through all oranges in multiple rounds. In every round, rot the oranges to the adjacent position of oranges which were rotten in the last round.
    but its TC was O((R*C) * (R *C)).
    Then I used a queue. The idea is to use Breadth First Search. The condition of oranges getting rotten is when they come in contact with other rotten oranges. This is similar to breadth-first search where the graph is divided into layers or circles and the search is done from lower or closer layers to deeper or higher layers. In the previous approach, the idea was based on BFS but the implementation was poor and inefficient. To find the elements whose values are no the whole matrix had to be traversed. So that time can be reduced by using this efficient approach of BFS. 
    Total TC - O( R *C)

    Try solving now

    2. Subtree of Another Tree

    Easy
    10m average time
    90% success
    0/40
    Asked in companies
    MicrosoftFacebookAmazon

    Given two binary trees T and S, check whether tree S has exactly the same structure and node values with a subtree of T, i.e., check if tree S is a subtree of the tree T.

    A subtree of a tree T is a tree S consisting of a node in T and all of its descendants in T. The subtree corresponding to the root node is the entire tree; the subtree corresponding to any other node is called a proper subtree.

    Problem approach

    I used serialization of a tree ie converting a tree into a string and matching that with all the serialization outputs of all the subtrees with that tree. Below is the following approach.
    class Solution {

    public boolean isSubtree(TreeNode root, TreeNode subRoot) {
    String s1 = serialize(root);
    String s2 = serialize(subRoot);

    return s1.indexOf(s2)!= -1;
    }
    public String serialize(TreeNode root) {
    if(root==null)
    return "#";
    return root.val+":"+serialize(root.left)+":"+serialize(root.right);
    }
    }

    I was able to pass most of the tescase scenarios.

    Try solving now
    02
    Round
    Medium
    Video Call
    Duration60 Minutes
    Interview date8 Jul 2022
    Coding problem2

    The round was at 12 afternoon. The interviewer was very polite . The round was based on probem solving skills. camera was on.

    1. Valid Parentheses

    Easy
    10m average time
    80% success
    0/40
    Asked in companies
    AmazonIntuitOracle

    You're given a string 'S' consisting of "{", "}", "(", ")", "[" and "]" .


    Return true if the given string 'S' is balanced, else return false.


    For example:
    'S' = "{}()".
    
    There is always an opening brace before a closing brace i.e. '{' before '}', '(' before ').
    So the 'S' is Balanced.
    
    Problem approach

    I was given a XML file. I need to validate if it is a valid file or not. I was given three apis 1. isClosedTag() 2. isOpenTag() 2. getTagName()

    I had no clue how a valid XML looks like . So I asked the interviewer to give me an example. I discussed some inputs.
    I then chose STACK to solve the question. The question was similar to validate parenthesis question.

    For every opening tag , I pushed the tag to stack.
    For every closing tag, I performed following approach
    1. check is the stack is empty -> return false
    2. check the top of stack. If top of stack is identical to current tag , then pop it.

    Similarly perform for each tag, And see if your stack is emoty at the end or not. 

    TC - O(n) --> n - number of tags

    Try solving now

    2. DBMS Question

    Explain Joins in a database.

    Problem approach

    Tip 1 : Always ask the kind of database SQL or NO-SQL.
    Tip 2 : If NO-SQL, it has i think no joins. If SQL explain INNER JOINS,LEFT JOIN,RIGHT JOIN
    Tip 3 : Always explain through small examples.

    03
    Round
    Medium
    Video Call
    Duration60 Minutes
    Interview date20 Aug 2022
    Coding problem2

    The round was BR round. The interviewer was SDM-2 at prime video org. The round was pretty difficult as I was grinded on my projects and leadership principles constantly.

    1. Convert Bst To The Greater Sum Tree

    Moderate
    30m average time
    70% success
    0/80
    Asked in companies
    CultfitMathworksIntuit

    You have been given a Binary Search Tree of integers. You are supposed to convert it to a greater sum tree such that the value of every node in the given BST is replaced with the sum of the values of all the nodes which are greater than the value of the current node in the tree.

    A Binary Search Tree is a tree, whose internal nodes each store a value greater than all the values in the node's left subtree and less than those in its right subtree.

    Note :

    You need to modify the given tree only. You are not allowed to create a new tree.
    
    For example:
    For the given binary search tree
    

    Example

    11 will be replaced by {15 + 29 + 35 + 40}, i.e. 119.
    2 will be replaced by {7 + 11 + 15 + 29 + 35 + 40}, i.e. 137.
    29 will be replaced by {35 + 40}, i.e. 75.
    1 will be replaced by {2 + 7 + 11 + 15 + 29 + 35 + 40}, i.e. 139.
    7 will be replaced by {11 + 15 + 29 + 35 + 40}, i.e. 130.
    15 will be replaced by {15 + 29 + 35 + 40}, i.e. 104.
    40 will be replaced by 0 {as there is no node with a value greater than 40}.
    35 will be replaced by {40}, i.e. 40.
    
    Problem approach

    First I used bruteforce approach .
    This method doesn’t require the tree to be a BST. Following are the steps. 
    Traverse node by node(Inorder, preorder, etc.) 
    For each node find all the nodes greater than that of the current node, sum the values. Store all these sums. 
    Replace each node value with their corresponding sum by traversing in the same order as in Step 1. 

    Then I optimised by using property of BST
    By leveraging the fact that the tree is a BST, we can find an O(n) solution. The idea is to traverse BST in reverse inorder. Reverse inorder traversal of a BST gives us keys in decreasing order. Before visiting a node, we visit all greater nodes of that node. While traversing we keep track of the sum of keys which is the sum of all the keys greater than the key of the current node.

    Try solving now

    2. Technical Questions

    I was aked questions on elastic search as I mentioned it as one of my tech stack in CV, I was asked about kafka and relations between producer and consumers. Cross questioning was there.

    Problem approach

    Tip 1 : You dont need to have answer to all scenarios the interviewer asks. Humbly say NO if havent encountered one
    Tip 2 : Please dont fake any scenario. Try to list down all the questions and prepare a well structured answer to them
    Tip 3 : Always have a smile on your face while interacting in the conversation. A lot depends on how you showcase yourself.

    Here's your problem of the day

    Solving this problem will increase your chance to get selected in this company

    Skill covered: Programming

    How do you remove whitespace from the start of a string?

    Choose another skill to practice
    Similar interview experiences
    company logo
    SDE - 1
    3 rounds | 5 problems
    Interviewed by Amazon
    3085 views
    0 comments
    0 upvotes
    company logo
    SDE - 1
    4 rounds | 8 problems
    Interviewed by Amazon
    2295 views
    1 comments
    0 upvotes
    company logo
    SDE - 1
    3 rounds | 6 problems
    Interviewed by Amazon
    1593 views
    0 comments
    0 upvotes
    company logo
    SDE - 1
    4 rounds | 8 problems
    Interviewed by Amazon
    8962 views
    0 comments
    0 upvotes
    Companies with similar interview experiences
    company logo
    SDE - 1
    4 rounds | 5 problems
    Interviewed by Microsoft
    58238 views
    5 comments
    0 upvotes
    company logo
    SDE - 1
    4 rounds | 8 problems
    Interviewed by Samsung
    12649 views
    2 comments
    0 upvotes
    company logo
    SDE - 1
    4 rounds | 8 problems
    Interviewed by Microsoft
    5983 views
    5 comments
    0 upvotes