Medium · Prefix Sum

Array Manipulation

Given n (an array of n zeros, indexed 1..n) and m queries [a, b, k] that each add k to every position from a to b inclusive, return the largest value in the array after all queries are applied.

Examples

Example 1

n=5, 3 queries

Output: max = 200

Example 2

n=8, 3 queries

Output: max = 10

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Prefix Sum problems