Apply Many Range Additions to an Array

Asked at Google · Coding Questions · Difficulty: Medium

You keep an array of `n` integers and receive a batch of `q` updates. Each update adds the same amount to every element in a contiguous index range. Return the array after all updates. The batch can be large and the ranges wide, so touching every element of every range is too slow.

Loading the problem…