Find all missing numbers from a given sorted array | Function to find the missing elements ; Initialize an array with zero of size equals to the maximum element in the array ; Make b [ i ] = 1 if i is present in the array ; If the element is present make b [ arr [ i ] ] = 1 ; Print the indices where b [ i ] = 0 ; Given array arr [ ] ; Function call
def printMissingElements ( arr , N ) : NEW_LINE INDENT b = [ 0 ] * ( arr [ N - 1 ] + 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT b [ arr [ i ] ] = 1 NEW_LINE DEDENT for i in range ( arr [ 0 ] , arr [ N - 1 ] + 1 ) : NEW_LINE INDENT if ( b [ i ] == 0 ) : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 6 , 7 , 10 , 11 , 13 ] NEW_LINE N = len ( arr ) NEW_LINE printMissingElements ( arr , N ) NEW_LINE