Compute the maximum difference in score between two players in a game sequence.
You are given an array of integers representing points gained or lost during a game. Choose a contiguous segment of the sequence that maximizes the score difference between two competing outcomes derived from that segment.
A common interpretation is to find the largest possible difference between the best and worst scoring parts of the game, which can be reduced to tracking the maximum subarray-style gain over the array. Your task is to return the score difference according to the game’s scoring rule.
Write a function that determines the required difference efficiently for the given sequence.
Example 1
Input
5 1 -2 3 4 -1
Output
7
Explanation
The best contiguous gain is achieved by taking the segment [3, 4], which contributes 7 in total.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.