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

SDE - 1

Amazon
upvote
share-icon
3 rounds | 12 Coding problems

Interview preparation journey

expand-icon
Tip
Tip

Only write those things in the resume which you are confident of and keep practising.

Application process
Where: Other

Interview rounds

01
Round
Easy
Coding Test - Pen and paper
Duration
Interview date7 Sep 2019
Coding problem3

This is a written round on paper for everyone. 2 out of  3 must be correct covering every single edge cases to qualify for the next round and the only most optimal solution was to be considered. 

1. Kadane's Algorithm

Moderate
26m average time
0/80
Asked in companies
PayPalExpedia GroupGoldman Sachs

Given an array arr of N integers. Find the contiguous sub-array with maximum sum.

 

Input:

The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N denoting the size of array. The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.

 

Output:

Print the maximum sum of the contiguous sub-array in a separate line for each test case.

 

Constraints:

1 ≤ T ≤ 110

1 ≤ N ≤ 106

-107 ≤ A[i] <= 107

 

Example:

Input

2

5

1 2 3 -2 5

4

-1 -2 -3 -4

Output

9

-1

Problem approach

I used Kadane algorithm to solve this question. And wrote a clean code with handling of negative numbers also.

Try solving now

2. Minimum Cost of ropes

Easy
20m average time
80% success
0/40
Asked in companies
ArcesiumUberOptum

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 sum of their lengths. The task is to connect the ropes with minimum cost.

 

Input:

The first line of input contains an integer T denoting the number of test cases. The first line of each test case is N where N is the number of ropes. The second line of each test case contains N input L[i],length of ropes.

 

Output:

For each testcase, print the minimum cost to connect all the ropes.

 

Constraints:

1 ≤ T ≤ 100

1 ≤ N ≤ 106

1 ≤ L[i] ≤ 106

 

Example:

Input:

2

4

4 3 2 6

5

4 2 7 6 9

 

Output:

29

62

Problem approach

I solved this question using priority queue by inserting all elements in priority queue and then taking maximum two out of them and pushing their sum again to priority queue.

Try solving now

3. Left View of Binary Tree

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

Given a Binary Tree, print Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. The task is to complete the function leftView(), which accepts root of the tree as argument.

 

Left view of following tree is 1 2 4 8.

 

         1

      /     \

    2        3

  /     \    /    \

 4     5   6    7

  \

    8    

 

Example 1:

 

Input:

  1

/  \

3    2

Output: 1 3

 

Example 2:

 

Input:

Output: 10 20 40

Problem approach

This was again very standard question and solved it using recursion.

Try solving now
02
Round
Easy
Face to Face
Duration
Interview date7 Sep 2019
Coding problem2

1. Triplets in Binary Tree

Print all three nodes in a binary tree such that sum of all these three nodes is greater than given x and these three nodes must hold the relationship of grandparent-parent-child. Expected Complexity – O(n)

 

Problem approach

I thought of recursion approach of preorder and then tried storing elements in a stack but could not solve this question. Then the interviewer moved to the next question.

2. Stickler Thief

Moderate
26m average time
0/80
Asked in companies
PayPalExpedia GroupGoldman Sachs

Stickler the thief wants to loot money from a society having n houses in a single line. He is a weird person and follows a certain rule when looting the houses. According to the rule, he will never loot two consecutive houses. At the same time, he wants to maximize the amount he loots. The thief knows which house has what amount of money but is unable to come up with an optimal looting strategy. He asks for your help to find the maximum money he can get if he strictly follows the rule. Each house has a[i] amount of money present in it.

 

Input:

The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each test case contains an integer n which denotes the number of houses. Next line contains space separated numbers denoting the amount of money in each house.

 

Output:

For each testcase, in a newline, print an integer which denotes the maximum amount he can take home.

 

Constraints:

1 <= T <= 200

1 <= n <= 104

1 <= a[i] <= 104

 

Example:

Input:

2

6

5 5 10 100 10 5

3

1 2 3

Output:

110

4

Problem approach

I told interviewer dynamic programming based on include current element to current sum or exclude that element and he asked me to write its code and I gave properly commented code for this.

Try solving now
03
Round
Easy
HR Round
Duration
Interview date7 Sep 2019
Coding problem7

1.

Tell me about yourself.

Problem approach

I gave him my basic introduction with previous experience and skills.

2.

Why are looking for a change, you recently joined a company and now again you are giving interviews.

Problem approach

I simply gave the reason that amazon is better than my previous company so wanted to join it.

3.

 Mutex vs Semaphores with a real-life example.

Problem approach

Gave him a proper definition of both and then gave him an example based on classical OS problems.

4.

Normalization and why it is done?

Problem approach

Gave him a basic definition and real-life example of a database of the store.

5.

Rest API.

Problem approach

I told him the definition of REST and then explained it through an example of my project in which REST API was used. 

6.

Rabbit MQ and Kafka.

Problem approach

I didn’t know anything about them so could not tell it to the interviewer.

7.

Write a shell script to parse a log file.

Problem approach

I didn’t mention anything like Rabbit MQ, Kafka, database in my resume but still he kept asking me these questions. I mentioned that I am familiar with the shell scripting in my resume but could not able to write the script as I didn’t remember the syntax and that’s a learning for me that don’t mention anything about anything if you are not very good about it.

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
3084 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
2294 views
1 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Amazon
1592 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
58237 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