Back to problems

Implement list overlap and dense-ranked word frequencies

Object-Oriented Programming · Amazon · Medium

Part A — Multiset Intersection Size Tally the Shorter Collection, Drain It Against the Longer One A multiset intersection is not the same thing as "how many distinct values do the two lists share." If a value shows up three times in one list and once in the other, it contributes exactly one element to the overlap — the smaller of the two multiplicities. So the whole problem reduces to pairing up occurrences greedily, one at a time. The naive way to do that pairing is a…

Checking your access…