GeeksforGeeks » Algorithms
maximum size stack
(2 posts)-
you're given a set of 'n' rectangular boxes B(i), 1 <= i <= n. the three dimensions of box B(i) are x1(i), x2(i) & x3(i).
your aim is to create a stack (keeping a box on other box) of maximum height. you can keep a box B(i) on box B(j) only when the area of faces in contact (of boxes B(i) & B(j)) holds following property-
face_area_in_contact(B(i)) <= face_area_in_contact(B(j))
find a strategy to get maximum height stack. of course you can rotate the box if you wish to put it on stack properly (i.e. it's your wish that which face of box B(i) should be kept in contact with box B(j)).
i'm not mentioning the complexity requirements, but your aim is to reduce TIME complexity. you can use what ever space you need.
-
Take the maximum dimension of each box and add them.It will give u the maximum height.
Reply
You must log in to post.