2171. Removing Minimum Number of Magic Beans

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2171

class Solution:
    def minimumRemoval(self, beans: List[int]) -> int:
        beans.sort()
        s, n = sum(beans), len(beans)
        return min(s - x * (n - i) for i, x in enumerate(beans))