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 |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 1266. Minimum Time Visiting All Points (1) | 2024.04.27 |
---|---|
leetcode 2855. Minimum Right Shifts to Sort the Array (0) | 2024.04.26 |
leetcode 1137. N-th Tribonacci Number (0) | 2024.04.25 |
leetcode 3065. Minimum Operations to Exceed Threshold Value I (0) | 2024.04.24 |
leetcode 3069. Distribute Elements Into Two Arrays I (0) | 2024.04.24 |
댓글