Last updated 4 years ago
Was this helpful?
when a has all elements of b a is superset of b in other words, b is A subset of a
iterate A element and check all elements belongs to B, if true A is a subset of B, in other words, B is a superset of A
const isSubsetOf = (s1, s2) => ![...s1.values()].some((v) => !s2.has(v)); const isSupersetOf = (s1, s2) => isSubsetOf(s2, s1);