Question: Approach First query is of Type 1 . Update A 2 . Now, array A becomes 2 , 2 , 4 , 3 , 1

Approach
First query is of Type 1. Update A2. Now, array A becomes 2,2,4,3,1.
Second query of of Type 2 with L=1,R=3.
Value of function is equal to F(1,1)+F(1,2)+F(1,3)+F(2,2)+F(2,3)+F(3,3)=2+4+8+2+6+4=
Thus, the answer is 26.
Function description
Complete the solve function provided in the editor. This function takes the following 4 parameters and returns the
required answer:
N : Represents the number of elements in array A
Q : Represents the number of queries
A: Represents the elements of array A
query: Represents the queries
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and
Test button).
The first line contains a single integer T, which denotes the number of test cases. T also specifies the
Approach First query is of Type 1 . Update A 2 .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!