find union and intersection of two arrays in java

Solutions on MaxInterview for find union and intersection of two arrays in java by the best coders in the world

showing results for - "find union and intersection of two arrays in java"
Marylou
23 Nov 2018
1static void findIntersection(int arry1[],int arry1size,int arry2[],int arry2size){
2    	HashSet<Integer> hs=new HashSet<Integer>();
3    	for(int i=0;i<arry1size;i++){
4    		for(int j=0;j<arry2size;j++){
5    			if(arry1[i]==arry2[j]){
6    				hs.add(arry1[i]);
7    			}
8    		}
9    	}
10    	
11    	System.out.println(hs);
12    }
similar questions