Find elements which are present in first array and not in second | C # efficient program to find elements which are not present in second array ; 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
using System ; using System . Collections . Generic ; class GfG { static void findMissing ( int [ ] a , int [ ] b , int n , int m ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < m ; i ++ ) s . Add ( b [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) if ( ! s . Contains ( a [ i ] ) ) Console . Write ( a [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 6 , 3 , 4 , 5 } ; int [ ] b = { 2 , 4 , 3 , 1 , 0 } ; int n = a . Length ; int m = b . Length ; findMissing ( a , b , n , m ) ; } }