I'm not sure if there's an algorithm that can solve this.
A given number of rectangles are placed side by side horizontally from left to right to form a shape. You are given the width and height of each.
How would you determine the minimum number of rectangles needed to cover the whole shape? i.e How would you redraw this shape using as few rectangles as possible?
I've can only think about trying to squeeze as many big rectangles as i can but that seems inefficient. Any ideas?
Edit: You are given a number n , and then n sizes: 2 1 3 2 5
The above would have two rectangles of sizes 1x3 and 2x5 next to each other. I'm wondering how many rectangles would i least need to recreate that shape given rectangles cannot overlap.