Hi all sharing my Amazon OA round.
Prior experience: 1.2 YOE
Current: Working at a Product based company
The recruiter contacted me for the SDE 1 position at Amazon. My resume got past the screening round and my OA round was scheduled.
Question 1: Minimum Health to Beat Game
It was a very straight forward question. Solved it in 2 minutes
Description:
You are playing a game that has n levels numbered from 0 to n - 1. You are given a 0-indexed integer array damage where damage[i] is the amount of health you will lose to complete the ith level.
You are also given an integer armor. You may use your armor ability at most once during the game on any level which will protect you from at most armor damage.
You must complete the levels in order and your health must be greater than 0 at all times to beat the game.
Return the minimum health you need to start with to beat the game.
Sample Test case:
Input: damage = [2,7,4,3], armor = 4
Output: 13
Explanation: One optimal way to beat the game starting at 13 health is:
On round 1, take 2 damage. You have 13 - 2 = 11 health.
On round 2, take 7 damage. You have 11 - 7 = 4 health.
On round 3, use your armor to protect you from 4 damage. You have 4 - 0 = 4 health.
On round 4, take 3 damage. You have 4 - 3 = 1 health.
Note that 13 is the minimum health you need to start with to beat the game.
https://leetcode.com/problems/minimum-health-to-beat-game/description/
Question 2: Minimum Operations to Make the Integer Zero
Description:
You are given an integer array and you need to perform some operations on the array to make all the elements equal to 0. in one operation you can select a prefix of the given array and increment or decrement all the elements of the prefix by 1
You have an array arr consisting of n integers. Find the minimum number of operations required to convert every element of this array to 0.
A prefix is a contiguous group of items that includes the first element in the cart. for example [1], [1,2], [1,2,3] are prefixes of [1,2,3,4,5]
Sample Test Case:
cart = [3,2,0,0,-1]
Output: 5
Explanation:
ops 1 => [2,2,0,0,-1] -> prefix length = 1
ops 2 => [1,1,0,0,-1] -> prefix length = 1
ops 3 => [0,0,-1,-1,-1] -> prefix length = 4
ops 4 => [-1,-1,-1,-1,-1] -> prefix length = 2
ops 5 => [0,0,0,0,0] -> prefix length = 5
Took me some time to figure my but after 5-10 mins was able to solve with all test cases passed.
Couldn't find the exact question but here is a similar question.
https://leetcode.com/problems/apply-operations-to-make-all-array-elements-equal-to-zero/description/
Other than Amazon also have interviews lined up with Myntra and Esper.
Would soon share the further experience