Bob Plays an exciting game known as "Product Game" In the Game, Bob has been provided an array of numbers of size N along with Qqueries. For each query, he is provided with integers L and R and he has to find the product of all elements in the array between this range inclusively. Bob's task is to find the difference between the maximum and minimum solutions among all the queries.
Note:
Task:
Find the difference between the maximum and minimum solutions among all the queries.
Function Description:
Complete the function solve provided in the editor. This function takes the following two parameters and returns the required answer:
T: Test Cases
N:Size of Array
A: Array of Numbers
Q: Number of queries
queries: 2-D Array of queries containing [L,R]
L:LowerIndex
R:UpperIndex
Input Format:
The first line contains an Integer T which is the number of the test cases.
Each Test Case will have the following :
The first line contain an integer N
the second line contains the array A
The third line contain an Integer Q
Next, Q lines contain two integers L and R in each lin
Output Format:
For each test case, print answer in a new line
Constraints
1≤T≤10
1≤N≤105
1≤A[i]≤105
1≤Q≤105
1≤[L≤R]≤N
T=1
N=5
A=[2,4,5,6,8]
Q=3
queries=[[1,4],[2,5],[3,3]]
For 1 query L = 1 & R = 4
Product of 1 query =2∗4∗5∗6=240
For 2 query L = 2 & R = 5
Product of 2 query =4∗5∗6∗8=960
Similarly Product of the Third query =5
So the difference between the maximum and minimum query =960−5=955