Skip to content

Instantly share code, notes, and snippets.

@lgutie16
Created July 18, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgutie16/40870f878727b09b80c860977e99310c to your computer and use it in GitHub Desktop.
Save lgutie16/40870f878727b09b80c860977e99310c to your computer and use it in GitHub Desktop.
Find if a multiset is subset of another multiset using multiplicity
function isSubset(a, b){
subset = true
a.forEach(function(value) {
subset = (b.multiplicity(value) > a.multiplicity(value)) && subset
});
return subset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment