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
function printMissingElements ( arr , N ) { let b = new Uint8Array ( arr [ N - 1 ] + 1 ) ; for ( let i = 0 ; i < N ; i ++ ) { b [ arr [ i ] ] = 1 ; } for ( let i = arr [ 0 ] ; i <= arr [ N - 1 ] ; i ++ ) { if ( b [ i ] == 0 ) { document . write ( i + " " ) ; } } } let arr = [ 6 , 7 , 10 , 11 , 13 ] ; let N = arr . length ; printMissingElements ( arr , N ) ;