Created
September 21, 2015 15:10
-
-
Save tanvir002700/076bd41527c55d03d3e4 to your computer and use it in GitHub Desktop.
Sparse Table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int RMQ(int i, int j) | |
{ | |
int k = log2(j-i); | |
int x = ST[k][i]; | |
int y = ST[k][j-(1<<k)+1]; | |
return A[x] <= A[y] ? x : y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment