Error
|
|
---|---|
@Ibrahim Nash | 6381 |
@blackshadows | 6329 |
@mb1973 | 5388 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@1905439 | 553 |
@terabaap123 | 508 |
@smitadiwedi1991 | 279 |
@DevanandJayakumar | 250 |
@atishagusain | 244 |
@gupta_10 | 226 |
@shubhamkhullar7 | 224 |
@nipun edara | 224 |
@balunagar | 204 |
@sharmachandan487 | 204 |
@arshjit_singh7 | 190 |
Complete Leaderboard |
Given an array A[ ] and its size N your task is to complete two functions a constructST function which builds the segment tree and a function RMQ which finds range minimum query in a segment tree .
Input:
The task is to complete two functions constructST and RMQ .
The constructST function builds the segment tree and takes two arguments the array A[ ] and the size of the array N .
It returns a pointer to the first element of the segment tree array .
The RMQ function takes 4 arguments the first being the segment tree st constructed, second being the size N and then third and forth arguments are the range of query a and b .The function RMQ returns the min of the elements in the array from index range a and b. There are multiple test cases. For each test case, this method will be called individually.
Output:
The function RMQ should return the min element in the array from range a to b .
Constraints:
1<=T<=100
1<=N<=10^3+1
1<=Q(no of queries)<=10000
0<=a<=b
Example:
Input (To be used only for expected output)
1
4
1 2 3 4
2
0 2 2 3
Output
1 3
Explanation
1. For query 1 ie 0 2 the element in this range are 1 2 3 and the min element is 1
2. For query 2 ie 2 3 the element in this range are 3 4 and the min element is 3
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes