1564. Put Boxes Into the Warehouse I




naive
sort boxes, then put them one by one into warehouse,
T: (mlogm + n^2), m is number of boxes, n is number of warehouses
DP
but can be more simple
greedy
like greedy idea, use warehouse itself
but if interview ask, you can't use in-place, how to achive space O(1)
sort boxes, from large to small, set to warehouse, then it'll abandon box which is too tall !
see leetcode solution 2: https://leetcode.com/problems/put-boxes-into-the-warehouse-i/solution/
Last updated
Was this helpful?