Create a visited array
vis = [ 0 ] * ( MAX ) NEW_LINE for i in range ( len ( interval ) ) : NEW_LINE INDENT start = interval [ i ] [ 0 ] NEW_LINE end = interval [ i ] [ 1 ] NEW_LINE vis [ start ] += 1 NEW_LINE vis [ end + 1 ] -= 1 NEW_LINE DEDENT