Find missing elements of a range | Print all elements of range [ low , high ] that are not present in arr [ 0. . n - 1 ] ; Create boolean list of size high - low + 1 , each index i representing wether ( i + low ) th element found or not . ; if ith element of arr is in range low to high then mark corresponding index as true in array ; Traverse through the range and print all elements whose value is false ; Driver Code
def printMissing ( arr , n , low , high ) : NEW_LINE INDENT points_of_range = [ False ] * ( high - low + 1 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( low <= arr [ i ] and arr [ i ] <= high ) : NEW_LINE INDENT points_of_range [ arr [ i ] - low ] = True NEW_LINE DEDENT DEDENT for x in range ( high - low + 1 ) : NEW_LINE INDENT if ( points_of_range [ x ] == False ) : NEW_LINE INDENT print ( low + x , end = " ▁ " ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 1 , 3 , 5 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE low , high = 1 , 10 NEW_LINE printMissing ( arr , n , low , high ) NEW_LINE