3334. Apple Redistribution into Boxes
My accepted Python solution to LeetCode problem 3334, Apple Redistribution into Boxes, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 12.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 12.4MB, accepted 2025-12-24.
class Solution(object):
def minimumBoxes(self, apple, capacity):
total_apples = sum(apple)
capacity.sort(reverse=True)
current_capacity = 0
for i, cap in enumerate(capacity):
current_capacity += cap
if current_capacity >= total_apples:
return i + 1
return len(capacity)