1580. Put Boxes Into the Warehouse II
Previous1579. Remove Max Number of Edges to Keep Graph Fully TraversableNext1581. Customer Who Visited but Did Not Make Any Transactions
Last updated
Last updated
**Input:** boxes = [1,2,2,3,4], warehouse = [3,4,1,2]
**Output:** 4
**Explanation:
**We can store the boxes in the following order:
1- Put the yellow box in room 2 from either the left or right side.
2- Put the orange box in room 3 from the right side.
3- Put the green box in room 1 from the left side.
4- Put the red box in room 0 from the left side.
Notice that there are other valid ways to put 4 boxes such as swapping the red and green boxes or the red and orange boxes.**Input:** boxes = [3,5,5,2], warehouse = [2,1,3,4,5]
**Output:** 3
**Explanation:
**It's not possible to put the two boxes of height 5 in the warehouse since there's only 1 room of height >= 5.
Other valid solutions are to put the green box in room 2 or to put the orange box first in room 2 before putting the green and red boxes.**Input:** boxes = [1,2,3], warehouse = [1,2,3,4]
**Output:** 3**Input:** boxes = [4,5,6], warehouse = [3,3,3,3,3]
**Output:** 0