Maximum Subarray Sum With One Deletion Problem
Maximum Subarray Sum With One Deletion Problem — ExecCode Medium DSA Practice
Solve the Maximum Subarray Sum With One Deletion problem on ExecCode. Free online medium DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given an integer array a. You may delete at most one element. The remaining elements must stay in their original order. Return the maximum sum of a non-empty contiguous subarray after deleting at most one element. Use a 64-bit integer. You are given: a — the array Return the maximum subarray sum after at most one deletion, as a 64-bit integer. The subarray must be contiguous and non-empty. Deleting an element is optional. An O(n) Kadane variant is the expected approach.
Examples
Input {'a': [1, -2, 3, 4]}; Output 8. Input {'a': [-1, -2, -3]}; Output -1. Input {'a': [5, -10, 5]}; Output 10
Constraints
1 <= a.length <= 100000 1000000000 <= a[i] <= 1000000000 The answer fits in a signed 64-bit integer
Practice Maximum Subarray Sum With One Deletion free on ExecCode. Browse DSA problems, topic map, and placement guides.