Function To find the required interval
function solve ( interval , N , Q ) { var Mark = Array ( Q ) . fill ( 0 ) ; for ( var i = 0 ; i < N ; i ++ ) { var l = interval [ i ] [ 0 ] - 1 ; var r = interval [ i ] [ 1 ] - 1 ; for ( var j = l ; j <= r ; j ++ ) Mark [ j ] ++ ; }