← 返回 google 的题目列表Find Maximum Subarray Sum Between Equal Elements
类型:online_judge
Given an array, such as [1, 2, 3, 2, 5, 3], find two indices i and j where i != j and array[i] = array[j]. Calculate the maximum sum of the subarray from array[i] to array[j]. Write a function to solve this problem. Assume the input array contains at most 10^5 elements, with element values ranging from -10^4 to 10^4.
Example:
Input: [1, 2, 3, 2, 5, 3]
Output: 6
Explanation: The maximum subarray sum from index 1 to index 3 is 2 + 3 + 2 = 6.
Example
Input
[1, 2, 3, 2, 5, 3]