1580. Put Boxes Into the Warehouse II

https://leetcode.com/problems/put-boxes-into-the-warehouse-ii/

from left, cal the min height

height = [3,3,1,1]

from right, cal max height with min

height = [3,3,1,2]

sort height: [1,2, 3,3]

sort box: [1,2,2,3,4]

put box into height one by one if matches, count++

greedy

like 1564 leetcode solution 2:

sort box desc, put into it, left can put or put into right

Last updated

Was this helpful?