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

Open every published interview problem, solution, scene, and memory room free, with no account.

More Prefix Sum problems