HackerEarth Test
Question:
A is an array 
Q is total no. of operations that will be performed
operations is an array of tuple (L, R, a, d)
A[i] = A[i] + B[i-L+1],  where L <= i <= R
and B is an arithmetic progression of the form B[n] = a + (n-1)*d
1 based indexing

TLDR: perform Q queries on a range of indices (L, R) of an array A with updates


Constraints:
1 <= A <= 10^5
1 <= Q <= 10^5
1 <= len(operations) <= Q
1 <= L <= R <= A
0 <= a, d <= 10^9

Example:
A = [2, 1, 1, 4]
Q = 2
operations = [(1, 1, 3, 1000), (2, 3, 7, 2)]

after performing given operations, final A will look like:
A = [5, 8, 10, 4]

explanation:
after op1: B = [3, 1003, ...], A = [5, 1, 1, 4]
after op2: B = [7, 9, 11, ...], A = [5, 8, 10, 4]

Source: HackerEarth test
Comments (4)