Find elements which are present in first array and not in second | Function for finding elements which are there in a [ ] but not in b [ ] . ; Store all elements of second array in a hash table ; Print all elements of first array that are not present in hash table ; Driver code
function findMissing ( a , b , n , m ) { let s = new Set ( ) ; for ( let i = 0 ; i < m ; i ++ ) s . add ( b [ i ] ) ; for ( let i = 0 ; i < n ; i ++ ) if ( ! s . has ( a [ i ] ) ) document . write ( a [ i ] + " " ) ; } let a = [ 1 , 2 , 6 , 3 , 4 , 5 ] ; let b = [ 2 , 4 , 3 , 1 , 0 ] ; let n = a . length ; let m = b . length ; findMissing ( a , b , n , m ) ;