Amazon Onsite DSA Round
Summary
I was asked two Data Structures and Algorithms questions during my onsite round at Amazon.
Full Experience
Two questions were asked
Question 1 Given an array and an integer x. You can remove one element either from left end or right end and subtract that number from x. Removal of element from left or right end is considered as one operation. You have to return minimum number of operations to make x = 0.
Question 2 There is an array of binary integer initially all 0. In each iteration all the multiple of that iteration number will be toggled like if it is 0 then it will become 1 and vice versa.
1st iteration all will be toggled to 1 2nd all multiples of 2 will be toggled. 3rd iteration all multiples of 3 will be toggled. so on.
At the end return all the indexes which is 1
Interview Questions (2)
Minimum Operations to Make X Zero by Removing Ends
Given an array and an integer x. You can remove one element either from left end or right end and subtract that number from x. Removal of element from left or right end is considered as one operation. You have to return minimum number of operations to make x = 0.
Toggle Multiples in Binary Array
There is an array of binary integer initially all 0. In each iteration all the multiple of that iteration number will be toggled like if it is 0 then it will become 1 and vice versa.
1st iteration all will be toggled to 1 2nd all multiples of 2 will be toggled. 3rd iteration all multiples of 3 will be toggled. so on.
At the end return all the indexes which is 1