Maximum Subarray Score (First + Last - Sum of Middle)

Given an integer array nums. For a contiguous subarray nums[L..R] with length at least 2, its score is:

nums[L] + nums[R] - (sum of all elements strictly between L and R)

Return the maximum sc...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: