Amazon OA | SDE2 Interview Questions

amazon logo
amazon
SDE II
October 17, 202412 reads

Summary

I recently encountered a challenging online assessment for an SDE2 role at Amazon, which featured a unique problem involving array manipulation and prefix sums.

Full Experience

During my Amazon OA for the SDE2 position, I was presented with a problem that required careful thought about array transformations while maintaining specific conditions. The question involved deciding which elements to negate to maximize the count of negative elements, all while ensuring every prefix sum remained positive. I found the problem statement clear, and the provided example helped in understanding the constraints and expected output. It was an interesting problem that tested my greedy approach and understanding of array properties.

Interview Questions (1)

Q1
Maximize Negative Elements with Positive Prefix Sums
Data Structures & Algorithms

Given an array of N positive integers. You can make any number of elements in it negative such that every prefix sum of the array remains positive i.e >0. Find the maximum number of elements you can make negative.

Example:
Input: 5 2 3 5 2 3
Output: 3
Explanation: This can be converted to 5 -2 3 5 -2 -3

Constraints:
N is 10^5
Ai <= 10^9

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!