Array to store numbers that occur exactly in one interval till ith interval
var count1 = Array ( Q ) . fill ( 0 ) ; if ( Mark [ 0 ] == 1 ) count1 [ 0 ] = 1 ; for ( var i = 1 ; i < Q ; i ++ ) { if ( Mark [ i ] == 1 ) count1 [ i ] = count1 [ i - 1 ] + 1 ; else count1 [ i ] = count1 [ i - 1 ] ; } var maxindex ; var maxcoverage = 0 ; for ( var i = 0 ; i < N ; i ++ ) { var l = interval [ i ] [ 0 ] - 1 ; var r = interval [ i ] [ 1 ] - 1 ;