Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.03 KB

_1564. Put Boxes Into the Warehouse I.md

File metadata and controls

42 lines (30 loc) · 1.03 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 15, 2024

Last updated : June 15, 2024


Related Topics : Array, Greedy, Sorting

Acceptance Rate : 67.42 %


Solutions

Python

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