FastPrepFastPrep
Problem Brief

Maximum Size Subarray Sum

FULLTIMEOA

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.

Function Description

Complete the function maximumSizeSubarraySum in the editor.

maximumSizeSubarraySum has the following parameter:

  1. int a[]: an array of integers

Returns

int: the sum of all elements of array b

1Example 1

Input
a = {10, 20, 10, 9, 12, 14}
Output
17
Explanation
The sum of all elements of array b is 1 + 6 + 2 + 1 + 3 + 4 = 17.

Constraints

Limits and guarantees your solution can rely on.

a.length <= 105
public int maximumSizeSubarraySum(int[] a) {
  // write your code here
}
Input

a

{10, 20, 10, 9, 12, 14}

Output

17

Sign in to submit your solution.