Find all numbers in range [ 1 , N ] that are not present in given Array | Function to find the missing numbers ; Traverse the array arr [ ] ; Update ; Traverse the array arr [ ] ; If Num is not present ; Given Input ; Function Call
function getMissingNumbers ( arr ) { for ( let num of arr ) arr [ Math . abs ( num ) - 1 ] = - ( Math . abs ( arr [ Math . abs ( num ) - 1 ] ) ) for ( pos in arr ) if ( arr [ pos ] > 0 ) document . write ( ` ${ parseInt ( pos ) + 1 } ` ) } let arr = [ 5 , 5 , 4 , 4 , 2 ] getMissingNumbers ( arr )