Search
⌘K

Leetcode 2171. Removing Minimum Number of Magic Beans

Given an array of positive integers (bag counts), remove beans (only deletions allowed) so that every non-empty bag has the same count, minimizing total beans removed; equivalently choose a target count (typically one of the existing values) and either zero out smaller bags or reduce larger ones to that target, testable efficiently by sorting and using prefix/suffix sums.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.