An array is subset of another array
How can I efficiently check to see whether all the elements in an integer array are subset of all elements of another Array in java? For example [33 11 23] is subset of [11 23 33 42]. Thanks in advance. Make a HashSet out of the superset array. Check if each of the elements of the subset array are contained in the HashSet . This is a very fast operation. If you're not bound to using Arrays, any Java collection has the containsAll method: boolean isSubset = bigList.containsAll(smallList); This will do exactly what you want, efficiently. assume you want to check A is subset of B. put each