본문 바로가기
python-algorithm

leetcode 3074. Apple Redistribution into Boxes

by 무적김두칠 2024. 4. 25.

https://leetcode.com/problems/apple-redistribution-into-boxes/description/

 

1
2
3
4
5
6
7
8
class Solution:
    def minimumBoxes(self, apple: List[int], capacity: List[int]) -> int:
        total_apple = sum(apple)
        capacity.sort(reverse = True)
        for i in range(len(capacity)):
            if sum(capacity[:i+1]) >= total_apple:
                return i + 1
        
cs
반응형

댓글