Search
⌘K

Leetcode 3196. Maximize Total Cost of Alternating Subarrays

Partition the array into contiguous subarrays to maximize the sum of each segment's alternating-signed sum (cost(l,r) = nums[l] - nums[l+1] + ...). The challenge is deciding partition boundaries (i.e., which elements get plus or minus signs within segments) to maximize the total, with n up to 1e5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.