512. Maximum Alternating Subarray Sum

Medium
Array
Dynamic Programming

Description

Hints

Hint 1
How can Kadane's Algorithm help us?
Hint 2
If you convert all the numbers at odd indices to the negative version of that number, the problem simplifies to finding the maximum subarray sum.
Hint 3
However, this strategy needs you to start each subarray at an even index.
Hint 4
Do the same except converting all the numbers at even indices to the negative version of that number.

Statistics

Acceptance
39.9%
Submissions
10,914
Accepted
4,356