Maximum Size Subarray Sum

Problem Overview

  • Given an integer array a, for each index i find the size of the largest subarray that includes a[i] where a[i] is the maximum element.
  • Construct array b with b[i] as that size, and return the sum of all b[i].
  • Input: int array a (length ≤ 1e5). Output: int sum.
  • Real-world context: range dominance and window sizing in array analytics.
  • From Deshaw interviews; a classic coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: