Driver code
let arr = [ 3 , 5 , 4 , 8 , 6 , 1 ] ; let q_arr = new Array ( 5 ) ; q_arr [ 0 ] = new query ( 0 , 3 ) ; q_arr [ 1 ] = new query ( 4 , 5 ) ; q_arr [ 2 ] = new query ( 1 , 4 ) ; q_arr [ 3 ] = new query ( 0 , 1 ) ; q_arr [ 4 ] = new query ( 2 , 5 ) ; let n = arr . length ; let m = q_arr . length ; let d = 2 ; document . write ( " " ) ; printArray ( arr , n ) ;