Build the Segment Tree from the given array
int * st = constructST ( arr , n ) ; vector < vector < int > > Q = { { 1 , 3 } , { 0 , 2 } } ; for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { int max = getMax ( st , n , Q [ i ] [ 0 ] , Q [ i ] [ 1 ] ) ; int ok = 0 ; for ( int i = 30 ; i >= 0 ; i -- ) { if ( ( max & ( 1 << i ) ) != 0 ) ok = 1 ; if ( ! ok ) continue ; max |= ( 1 << i ) ; } cout << max << " ▁ " ; } return 0 ; }