728x90
https://leetcode.com/problems/apple-redistribution-into-boxes
class Solution:
def minimumBoxes(self, apple: List[int], capacity: List[int]) -> int:
sum = 0
for n in apple:
sum += n
print('sum: ' + str(sum))
capacity.sort(reverse=True)
c_sum = 0
for i in range(len(capacity)):
c_sum += capacity[i]
if c_sum >= sum:
break
return i + 1
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 2485. Find the Pivot Integer (0) | 2024.03.13 |
---|---|
[Leetcode] 791. Custom Sort String (0) | 2024.03.11 |
[Leetcode] 349. Intersection of Two Arrays (0) | 2024.03.10 |
[Leetcode] 2540. Minimum Common Value (0) | 2024.03.09 |
[Leetcode] 3005. Count Elements With Maximum Frequency (1) | 2024.03.08 |