Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LinkedHashMap table;
- for each element e of array A
- if table.get(e) != null
- table.put( e, table.get(e) + 1 )
- else
- table.put( e, 0 )
- //Do the same for array B
- for each element e of array B
- if table.get(e) != null
- table.put( e, table.get(e) + 1 )
- else
- table.put( e, 0 )
- Collection union(Collection coll1, Collection coll2) {
- Set union = new HashSet(coll1);
- union.addAll(new HashSet(coll2));
- return union;
- }
- Collection intersect(Collection coll1, Collection coll2) {
- Set intersection = new HashSet(coll1);
- intersection.retainAll(new HashSet(coll2));
- return intersection;
- }
- Collection nonOverLap(Collection coll1, Collection coll2) {
- Collection result = union(coll1, coll2);
- result.removeAll(intersect(coll1, coll2));
- return result;
- }
Add Comment
Please, Sign In to add comment