## Interview Question

Country: United States

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

It is more like 0-1 knapsack problem.

We need to maximize filled space and minimize empty space.

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

It's 2D bin packing problem. NP-complete

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

Make a tree of the available blocks. In every step, divide the leaf node with minimum extra space than required <or any other heuristic>, into two nodes.Recursively do this till all tiles are filled.

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

i can think of the below; let me kow if u see issues

1. Let the paper size is m x n
2. Small paper piece dimention: sm x sn
3. compute: pieces = modulus( m/sm ) * modulus( n/sn )
4. compute: pieces2 = modulus( m/sn ) * modulus( n/sm )
5. return max ( pieces2, pieces)

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

What if the paper is 21*12 and card is 7*5? In your solution you'll fit only
6 cards:
1. (7+7+7)*5
2. (7+7+7)*5
3. 2*21 unfilled space
But in better solution:
1. (7+7+7)*5
2. (5+5+5+5)*7
4. 1*7 unfilled space

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.

### 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.