Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6454
@blackshadows 6380
@mb1973 5710
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3709
@mantu_singh 3556
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Range Minimum Query
Medium Accuracy: 55.36% Submissions: 3510 Points: 4

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 .
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 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Range Minimum Query

Output Window