Range Increments
Start from a list of length zeros. Each item of updates is a triple [left, right, amount] meaning: add amount to every position from left through right, both ends included (positions are 0-based and left <= right always holds). Apply all the updates in order.
Return the final list. With no updates it is all zeros.
Example 1
length 5
updates [[1,3,2],[2,4,3]]
returns [0,2,5,5,3]
The first update adds 2 to positions 1 to 3, the second adds 3 to positions 2 to 4. Positions 2 and 3 get both.
Example 2
length 3
updates []
returns [0,0,0]
No updates, so three zeros.
Constraints
1 <= length <= 1000 <= len(updates) <= 1000 <= left <= right < length-100 <= amount <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.