Problem · Array
Maximum Length-K Window Sum over Sparse Segments
Learn this problemProblem statement
A very large array is represented by segments. Each row [start, end, value] assigns value to every integer index from start through end, inclusive. Indices not covered by any segment have value 0.
Return the maximum sum of any contiguous window containing exactly k indices. The expanded array may be too large to store, so process the sparse segments directly.
Function
maximumKWindowSum(segments: int[][], k: int) → longExamples
Example 1
segments = [[1,3,4],[6,7,1]]k = 3return = 12The window covering indices 1 through 3 contains [4,4,4] and has sum 12.
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026