You are given an array arr of n integers.
A subarray is a contiguous non-empty segment of the array. For any subarray arr[l..r] (0-indexed), define:
Your task is to compute the maximum possible value of X(l, r) over all subarrays of arr.
n
(the length of the array).
arr
of
n
integers (can be positive, zero, or negative).
min(subarray) + max(subarray)
over all possible non-empty contiguous subarrays.
n
(e.g.,
n
up to around
2 * 10^5
).