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
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024