Amazon Onsite DSA Round

amazon logo
amazon
July 23, 20256 reads

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)

Q1
Minimum Operations to Make X Zero by Removing Ends
Data Structures & Algorithms

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.

Q2
Toggle Multiples in Binary Array
Data Structures & Algorithms

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

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!