COINSM - Editorial

Problem Link:

Practice

Setter: saquib ul hassan

Difficulty:
EASY-MEDIUM

Prerequisites:
Array

Problem:
length N initially filled with 0’s. Later he was given Q queries each with three parameters L, R & W where W is the weight that has to be added to each element of the array in the index range L to R (index is 1 based). And display the array after all Q operations

Quick Explanation:
Perform two things in a single operation:
1- Add k-value to only lower_bound of a range.
2- Reduce upper_bound + 1 index by k-value.

After all operations, iterate over the array and do sum+=arr[i], and display the sum.

SOLUTION:

Setter

Time Complexity:
Lets say m is the number of queries and n is the length of an array
O(m + n)