Back to problems

Maximum Sum of Fixed-Length Subarray in a Sparse Interval Array

Algorithm · Amazon · Hard

Problem: Maximum Sum of a Fixed-Length Subarray in a Sparse Interval Array An integer array has length n, but its contents are supplied as a collection of constant-value intervals rather than as individual elements: A record [l, r, v] assigns the value v to every position from l through r, inclusive. Positions are numbered starting at 1. Every index that belongs to no interval contains 0. No two intervals overlap, and each interval satisfies 1 <= l <= r <= n. Find the…

Checking your access…