Find all missing numbers from a given sorted array | Function to find the missing elements ; Initialize diff ; Check if diff and arr [ i ] - i both are equal or not ; Loop for consecutive missing elements ; Given array arr [ ] ; Function call
function prletMissingElements ( arr , N ) { let diff = arr [ 0 ] - 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] - i != diff ) { while ( diff < arr [ i ] - i ) { document . write ( ( i + diff ) + " " ) ; diff ++ ; } } } } let arr = [ 6 , 7 , 10 , 11 , 13 ] ; let N = arr . length ; prletMissingElements ( arr , N ) ;