Multiset Check
MultiSet Check is the process of verifying whether two MultiSets contain the same elements. Unlike a regular set, a MultiSet can include duplicate values. Let's explain this concept with three examples below.
The two sets below have the same elements, although in different orders, so they are equal.
The two sets below have different sizes, so they aren’t equal.
The two sets below are the same size, but only contains the value 4, so they aren’t equal.
So, how can we determine if two arbitrary sets satisfy MultiSet equality? At first glance, it might seem sufficient to simply multiply all the values together, but would this really work?
In fact, there can be numerous counterexamples to the equation as shown below.
Last updated