All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 15, 2024
Last updated : June 15, 2024
Related Topics : Array, Greedy, Sorting
Acceptance Rate : 67.42 %
class Solution:
def maxBoxesInWarehouse(self, boxes: List[int], warehouse: List[int]) -> int:
for i in range(1, len(warehouse)) :
warehouse[i] = min(warehouse[i], warehouse[i - 1])
boxes.sort(reverse=True)
counter = 0
while boxes and warehouse :
if boxes[-1] <= warehouse[-1] :
counter += 1
boxes.pop()
warehouse.pop()
return counter