Created
July 18, 2018 17:36
-
-
Save lgutie16/40870f878727b09b80c860977e99310c to your computer and use it in GitHub Desktop.
Find if a multiset is subset of another multiset using multiplicity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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