Positive integers up to N that are not present in given Array | Function to find positive integers from 1 to N that are not present in the array ; Declare bitset ; Iterate from 0 to M - 1 ; Iterate from 0 to n - 1 ; Iterate from bset . _Find_first ( ) to bset . size ( ) - 1 ; Driver Code
def findMissingNumbers ( arr , n ) : NEW_LINE INDENT M = 15 NEW_LINE bset = [ 0 ] * M NEW_LINE for i in range ( M ) : NEW_LINE INDENT bset [ i ] = i NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT bset [ arr [ i ] - 1 ] = 0 NEW_LINE DEDENT bset = [ i for i in bset if i != 0 ] NEW_LINE for i in range ( len ( bset ) ) : NEW_LINE INDENT if ( bset [ i ] + 1 > n ) : NEW_LINE INDENT break NEW_LINE DEDENT print ( bset [ i ] + 1 ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 6 , 8 , 9 ] NEW_LINE n = len ( arr ) NEW_LINE findMissingNumbers ( arr , n ) NEW_LINE DEDENT