Prints intersection of arr1 [ 0. . m - 1 ] and arr2 [ 0. . n - 1 ]
static void printIntersection ( int [ ] arr1 , int [ ] arr2 ) { HashSet < int > hs = new HashSet < int > ( ) ; for ( int i = 0 ; i < arr1 . Length ; i ++ ) hs . Add ( arr1 [ i ] ) ; for ( int i = 0 ; i < arr2 . Length ; i ++ ) if ( hs . Contains ( arr2 [ i ] ) ) Console . Write ( arr2 [ i ] + " ▁ " ) ; }