1196. How Many Apples Can You Put into the Basket

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1196

class Solution:
    def maxNumberOfApples(self, weight: List[int]) -> int:
        weight.sort()
        s = 0
        for i, x in enumerate(weight):
            s += x
            if s > 5000:
                return i
        return len(weight)