Interview Question






Comment hidden because of low score. Click to expand.
1
of 1 vote

This is a dynamic programming question. First sort the boxes in descending order of area in O(n log n). Then for each box i, the maximum stack height is:

H(i) = Max (H(i-1), H(j) + h(i)) where L(i) < L(j) and W(i) < W(j)

FInally just pick the max height looking back from the array values.

- Ashish Kaila September 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Ashish lets consider boxes of dimensions below. Can you explain how will it work

box 1->5,4,2
box 2->5,3,1
box 3->8,6,3

- sacboy September 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ ashish instead of comparing both L and W just compare the area since it is possible L1<L2 and W1>W2 still area1 >area2

- sacboy September 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Check the box stacking problem - people.csail.mit.edu/bdean/6.046/dp/.

- bytestorm September 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@eepiyush: Why spam CC with OLD posts only.
Go to stackoverflow, and post there, your moron!

This problem I saw in GOOGLE section. I found "lol" presented a complete solution to this. Why the fucking asshole you need to repost... if you can't get the solution, why don't ask it there!

- anonymous September 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Didn't wish to comment. But your constantly rude and uncouth remarks irritate far more than seeing a question being repeated

- RG September 14, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys, this is NOT a duplicate question.

All the solutions above work only when using multiple (duplicate) instances of a box are allowed. However, @eepiyush has clearly mentioned that "you can use each box only once"

Please reconsider your solutions

- Kushagra Sinha November 17, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More