I have a collection as follows
Map<String, Set<Long>> myMap = new HashMap<>();
I want to find out if any entry in this map has set which is contained in another entry of same map.
For example, lets say map has the following 5 entries
a - {1, 2, 3}
b - {4, 5}
c - {1}
d - {2, 3}
e - {5}
f - {6}
So, it has the following overlapping entries as set maybe
a - {1, 2, 3} and c - {1}
b - {4, 5} and e - {5}
a - {1, 2, 3} and d - {2, 3}
Or just list of Set for keys like
a and c
b and e
a and d
I could iterate each of the keyset and then use disjoint or anyMatch for each set, but I was wondering if there is an optimized way (Java 8, 9, 10, 11).