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

Software Developer

Amazon
upvote
share-icon
2 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Easy
Online Coding Interview
Duration90 minutes
Interview date28 Aug 2015
Coding problem2

Multiple choice questions pretty much covered everything. This included details of big O notation , concepts from computer organisation etc . Be a little careful while writing outputs as there might be misleading options.

1. Evaluation of postfix expression

Easy
15m average time
90% success
0/40
Asked in companies
eBayDirectiSlice

An expression is called the postfix expression if the operator appears in the expression after the operands.

Example :

Infix expression: A + B  *  C - D 

Postfix expression:  A B + C D - *

Given a postfix expression, the task is to evaluate the expression. The answer could be very large, output your answer modulo (10^9+7). Also, use modular division when required.

Note:
1. Operators will only include the basic arithmetic operators like '*', '/', '+', and '-'.

2. The operand can contain multiple digits. 

3. The operators and operands will have space as a separator between them.

4. There won’t be any brackets in the postfix expression.
Problem approach

Algorithm :
1) Create a stack to store operands (or values). 
2) Scan the given expression and do the following for every scanned element. 
…..a) If the element is a number, push it into the stack 
…..b) If the element is an operator, pop operands for the operator from the stack. Evaluate the operator and push the result back to the stack 
3) When the expression is ended, the number in the stack is the final answer

Try solving now

2. Binary Tree Leaves to Doubly Linked List.

Easy
15m average time
80% success
0/40
Asked in companies
HSBCAmazon

You are given an arbitrary binary tree with N nodes numbered from 1 to N. Your task is to remove all the leaf nodes from the tree and return them as the nodes of a doubly linked list. Also, you have to use the existing tree class for the doubly linked list with the left and the right pointers may act as the previous and next pointers of the nodes of the list.

A leaf of a binary tree is the node which does not have a left child and a right child.

For Example:
Given a binary tree - 

alt txt

Doubly Linked List is -
4 5 3 
And after removal of all the leaves, the inorder traversal of the tree will look like - 
2 1

Note:

1. Two nodes may have the same value associated with them.
2. The root node will be fixed and will be provided in the function.
3. The order of nodes in the doubly linked list should be the order of leaves in the tree from left to right.
3. You need to modify the binary tree in place and you only need to return the head of the doubly linked list
Problem approach

The idea is to traverse all the leaves and connect them by changing their left and right pointers. We also need to remove them from the Binary Tree by changing left or right pointers in parent nodes. 
One way to solve this is to add the leaves at the beginning of the current linked list and update the head of the list using the pointer to head pointer. Since we insert at the beginning, we need to process leaves in reverse order. For reverse order, we first traverse the right subtree, then the left subtree. We use return values to update left or right pointers in parent nodes.

Try solving now
02
Round
Easy
Face to Face
Duration45 minutes
Interview date28 Aug 2015
Coding problem2

Building part was quite easy . Should have a little practice of writing code on paper. Be careful about edge cases . The interviewer took it pretty seriously.

1. Total Unique Paths

Moderate
25m average time
80% success
0/80
Asked in companies
SAP LabsAdobeDirecti

You are present at point ‘A’ which is the top-left cell of an M X N matrix, your destination is point ‘B’, which is the bottom-right cell of the same matrix. Your task is to find the total number of unique paths from point ‘A’ to point ‘B’.In other words, you will be given the dimensions of the matrix as integers ‘M’ and ‘N’, your task is to find the total number of unique paths from the cell MATRIX[0][0] to MATRIX['M' - 1]['N' - 1].

To traverse in the matrix, you can either move Right or Down at each step. For example in a given point MATRIX[i] [j], you can move to either MATRIX[i + 1][j] or MATRIX[i][j + 1].

Problem approach

We have a matrix with n rows and m columns, where each cell, matrix[A][B], denotes whether it is accessible or not.
We will use recursion to solve this problem. We know that the number of ways to reach a cell is the sum of the number of ways to reach the cell to its left and the number of ways to reach the cell above it. Therefore:
No. of ways to reach matrix[i][j] = No. of ways to reach matrix[i-1][j] + No. of ways to reach matrix[i][j-1]
This is because we can only go right or downward from any cell.
Now, we start from a cell and perform recursion to find the number of ways to reach cell (n-1, m-1): 
recur(matrix, n-1, m-1) = recur(matrix, n-2, m-1) + recur(matrix, n-1, m-2)
For each cell, we will check if it is accessible or not. If it is not, we simply return 0, as there is no way to reach it. The base condition would be that if cell (0,0) is accessible, then the number of ways to reach it is 1.
Time Complexity: O(2^(rows+columns))
Auxiliary Space Used: O(rows+columns)

The above solution (recursive) was exponential. We are visiting multiple states over and over, and then recursing for them, which we can surely avoid. To avoid revisiting states that have already been visited, we can store them in a dp array, so that they can be accessed as and when needed. This approach is known as Dynamic Programming.
We know that for any cell (i, j), the number of paths to reach it would be the number of paths to reach cell (i-1, j) + the number of paths to reach cell (i, j-1).
For any accessible cell matrix[i][j], we maintain the count of number of paths to reach this cell in a separate two-dimensional array dp[i][j], where dp[i][j] = dp[i-1][j] + dp[i][j-1], given that cell (i, j) is accessible.
We return the value of dp[i][j] as the answer.
Time Complexity: O(n*m), considering the number of rows is n and columns is m.
Space Complexity: O(n*m), considering the number of rows is n and columns is m.

Try solving now

2. Count ways to reach the n’th stair

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

You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair.


Each time, you can climb either one step or two steps.


You are supposed to return the number of distinct ways you can climb from the 0th step to the Nth step.

Note:

Note: Since the number of ways can be very large, return the answer modulo 1000000007.
Example :
N=3

Example

We can climb one step at a time i.e. {(0, 1) ,(1, 2),(2,3)} or we can climb the first two-step and then one step i.e. {(0,2),(1, 3)} or we can climb first one step and then two step i.e. {(0,1), (1,3)}.
Problem approach

The question can be approached using recursion. The person can reach nth stair from either (n-1)th stair or from (n-2)th stair. Hence, for each stair n, find out the number of ways to reach n-1th stair and n-2th stair and add them to give the answer for the nth stair. Therefore the expression for such an approach comes out to be : ways(n) = ways(n-1) + ways(n-2)

This is an expression for Fibonacci numbers only, where ways(n) is equal to Fibonacci(n+1). 
Time Complexity: O(2^n) 
The above solution can be optimised using dynamic programming. Maintain an array dp[] and fill it in bottom up manner using the relation :
Dp[i] = dp[i-1] + dp[i-2] for i>=2 
Time complexity: O(N)
Auxiliary Space: O(N)

Try solving now

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
Software Developer
2 rounds | 4 problems
Interviewed by Amazon
1117 views
0 comments
0 upvotes
company logo
Software Developer
4 rounds | 6 problems
Interviewed by Amazon
1082 views
0 comments
0 upvotes
company logo
Software Developer
3 rounds | 5 problems
Interviewed by Amazon
1148 views
0 comments
0 upvotes
company logo
Software Developer
3 rounds | 6 problems
Interviewed by Amazon
970 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Developer
5 rounds | 14 problems
Interviewed by Microsoft
4029 views
1 comments
0 upvotes
company logo
Software Developer
6 rounds | 12 problems
Interviewed by SAP Labs
2912 views
0 comments
0 upvotes
company logo
Software Developer
4 rounds | 6 problems
Interviewed by SAP Labs
1075 views
0 comments
0 upvotes