Practice Removing Minimum Number of Magic Beans
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Removing Minimum Number of Magic Beans
Problem Statement
You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag. Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags. Return the minimum number of magic beans that you have to remove.
Source: Removing Minimum Number of Magic Beans on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
beans = [4,1,6,5]
4
# Example 2
beans = [2,10,3,2]
7
Constraints
Related LeetCode Problems
Practice more problems similar to Removing Minimum Number of Magic Beans.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.