text: Build the Segment Tree from the given array
code: int [ ] st = constructST ( arr , n ) ; int [ , ] Q = { { 1 , 3 } , { 0 , 2 } } ; for ( int i = 0 ; i < Q . GetLength ( 0 ) ; i ++ ) { int max = getMax ( st , n , Q [ i , 0 ] , Q [ i , 1 ] ) ; int ok = 0 ; for ( int j = 30 ; j >= 0 ; j -- ) { if ( ( max & ( 1 << j ) ) != 0 ) ok = 1 ; if ( ok <= 0 ) continue ; max |= ( 1 << j ) ; } Console . Write ( max + " ▁ " ) ; } } }