Range Add Queries (Difference Array)

Programming Interview Hard 7 views
Back to Questions

Problem Description

For each testcase you get n and q updates. Each update adds val to all positions l..r (1-based). After all updates output final array.

Input Format

First integer t. For each: n q, then q lines: l r val.

Output Format

t lines final arrays.

Sample Test Case

Input:
1 5 3 1 3 10 2 5 -2 5 5 7
Output:
10 8 8 -2 5

Constraints

Sum of n+q over all testcases

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next