items[i] is the kind of the i-th part. Throw out exactly removals parts so that as few distinct kinds as possible stay in the box.
Return that smallest number of kinds.items=[7, 7, 2, 9, 9, 9], removals=2 → 2
Throwing out both 7s leaves kinds 2 and 9. Two kinds cannot go with two removals: the rarest (2) costs one removal and the next (7) costs two more.
items=[4, 1, 4, 3], removals=4 → 0
Everything is removed, no kinds remain.
items=[5, 6, 5], removals=0 → 2
items=[7, 7, 2, 9, 9, 9], removals=2
2
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.