Problem · Array
Make the Array Positive
Learn this problemProblem statement
An operation replaces any one array value with any signed 64-bit integer. An array is positive when every contiguous subarray of length greater than one has non-negative sum. Return the minimum operations required.
Function
getMinOperations(arr: int[]) → intExamples
Example 1
arr = [2,5,-8,-1,2]return = 1Replacing -8 with a sufficiently large positive value makes every length-at-least-two subarray non-negative.
Constraints
1 <= arr.length <= 100000-10^9 <= arr[i] <= 10^9