# Amazon Interview Experience -Offcampus 2021

I had a referral for an **SDE-1 new grad** from Linkedin and after 10 days I got my OA for the same.

**Online Assessment**

There were 2 questions, one is based on the **heap,** and the other is on **BFS**. I manage to solve both.

1. You have some number of sticks with positive integer lengths. These lengths are given as an array sticks, wheresticks[i]is the length of the ith stick.You can connect any two sticks of lengths x and y into one stick by paying a cost ofx + y. You must connect all the sticks until there is only one stick remaining.Returnthe minimum cost of connecting all the given sticks into one stick in this way.Input:sticks = [2,4,3]Output:14Explanation:You start with sticks = [2,4,3].

1. Combine sticks 2 and 3 for a cost of 2 + 3 = 5. Now you have sticks = [5,4].

2. Combine sticks 5 and 4 for a cost of 5 + 4 = 9. Now you have sticks = [9].

There is only one stick left, so you are done. The total cost is 5 + 9 = 14.

2. Given the cost matrix and the initial position of the robot in matrix. Calculate the minimum cost to reach the given destination position.Input:

{ { 1, 2, 3 },{ 4, 8, 2 },{ 1, 5, 3 } };

output: 8

After 3 months they contacted the student who manage to solve all problems ( As they are not considering 2021 grad at first as they have to give final exams this is the reason they contacted after 3 months). There are around 25 students in the informative call where they are explaining about the next interviews.

I had 2 Technical and 1 Managerial Round on the same day

**2. Technical Round 1**

The round lasted about 1 hour and started with my introduction ( for 5 to 7 minutes ).

Then she directly jumps to coding questions

1. Given an m x n board of characters and a list of strings words, returnall words on the board.Each word must be constructed from letters of sequentially adjacent cells, whereadjacent cellsare horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.Input:board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]Output:["eat","oath"]2. In the stream of data where timestamp is mentioned and we have sort it according to start and end time.

After the coding questions, she asked me around 5 Amazon LP questions.

**3. Technical Round 2**

Starting with my Introduction and some questions on my projects and experience.

He asked 3 coding questions

Then he directly jumps to coding questions

1. DP Question: Given an array of positive integers, replace each element in the array such that the difference between adjacent elements in the array is less than or equal to a given target. We need to minimize the adjustment cost, that is the sum of differences between new and old values. We basically need to minimize ∑|A[i] – Anew[i]| where 0 ≤ i ≤ n-1, n is size of A[] and Anew[] is the array with adjacent difference less that or equal to target.

Assume all elements of the array is less than constant M = 100.Examples:Input:arr = [1, 3, 0, 3], target = 1Output:Minimum adjustment cost is 3Explanation:One of the possible solutions

is [2, 3, 2, 3]https://www.geeksforgeeks.org/find-minimum-adjustment-cost-of-an-array/2. Find LCA of 2 given Node: https://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/3. Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.You can assume that you can always reach the last index.Example:Input:nums = [2,3,1,1,4]Output:2

https://leetcode.com/problems/jump-game-ii/

**3. Managerial Round**

Lasted about 20 min

Long discussion on my projects and experience + asked a few questions like

- What are SDLC and its type?
- Difference between Thread and Process?

the round ended with a few Amazon LP Questions.

After this round, I got mail that I have another round after 5 days

**4. Bar Raiser Round**

There is 2 Interviewer ( **SDE-Manager and SDE-2 **) on the same call.

**SDEM **started with his introduction and asked a few LP questions. SDE-2 came and was given 1 coding question related to file handling.

`Question : Given a file which consist of data in row and columns and we have to print of every row and column sum.`

I was given an approach to reading files in C++ and maintaining 2 array sums for row and column. we also discuss many edge cases like how to determine the number of rows, columns and also dynamically create a memory for a 2d array and store it in it.

**Result: After 3 days I got rejection mail.**

**Hints from my mistakes:**

- Don’t ignore the edge cases and discuss them properly.
- Give proper LP answers ( In the STAR method ) as amazon really gives weightage to it.
- Don’t jump to coding directly.

You can connect with me: **here**