Amazon OA | SDE2 Interview Questions
- Posted
- 17 Oct 2024
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.
How it went
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.
Questions asked (1)
- 01
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 to5 -2 3 5 -2 -3
Constraints:
N is 10^5
Ai <= 10^9