Problem · Array
Maximum Size Subarray Sum
Given an array a, create another array b where b[i] is the size of the maximum subarray which includes a[i] and a[i] is the maximum element in that subarray.
Return the sum of all elements of array b.
Complete the function maximumSizeSubarraySum in the editor.
maximumSizeSubarraySum has the following parameter:
int a[]: an array of integers
Returns
int: the sum of all elements of array b
Examples
01 · Example 1
a = {10, 20, 10, 9, 12, 14}
return = 17The sum of all elements of array
b is 1 + 6 + 2 + 1 + 3 + 4 = 17.Constraints
a.length <= 105
More The D. E. Shaw Group problems
public int maximumSizeSubarraySum(int[] a) {
// write your code here
}
a{10, 20, 10, 9, 12, 14}
expected17
sign in to submit