12. Maximum Subarray Sum with One Deletion
Input: arr = [1,-2,0,3]
Output: 4
Explanation: Because we can choose [1, -2, 0, 3] and drop -2, thus the subarray [1, 0, 3] becomes the maximum value.Input: arr = [1,-2,-2,3]
Output: 3
Explanation: We just choose [3] and it's the maximum sum.Input: arr = [-1,-1,-1,-1]
Output: -1
Explanation: The final subarray needs to be non-empty. You can't choose [-1] and delete -1 from it, then get an empty subarray to make the sum equals to 0.Solution: (Kadane's Algorithm)

Previous11. Maximum Number of Non-Overlapping Subarrays With Sum Equals TargetNext13. Shortest Subarray with Sum at Least K (Negative Numbers)
Last updated