Find least non | Python3 program to find the least non - overlapping number from a given set intervals ; Function to find the smallest non - overlapping number ; Create a visited array ; Find the first missing value ; Driver code
MAX = int ( 1e5 + 5 ) NEW_LINE def find_missing ( interval ) : NEW_LINE INDENT 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 for i in range ( 1 , MAX ) : NEW_LINE INDENT vis [ i ] += vis [ i - 1 ] NEW_LINE if ( vis [ i ] == 0 ) : NEW_LINE INDENT print ( i ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT interval = [ [ 0 , 14 ] , [ 86 , 108 ] , [ 22 , 30 ] , [ 5 , 17 ] ] NEW_LINE find_missing ( interval ) NEW_LINE