Question: PYTHON 3 Given a set of n rectangles. Ith rectangle has length[i] length and breadth[i] breadth. One rectangle can overlap another rectangle, if the former

PYTHON 3

Given a set of n rectangles. Ith rectangle has length[i] length and breadth[i] breadth. One rectangle can overlap another rectangle, if the former has both >= length as well as >= breadth than the latter. We dont consider rotations of rectangles while considering overlapping. E.g. a 3 x 5 rectangle can overlap 2 x 4 rectangle, but not a 4 x 2 rectangle. A 3 x 5 rectangle also overlaps rectangles of sizes 3 x 4, 2 x 5, as well as 3 x 5 (another rectangle with same dimensions) We want to partition these rectangles into different groups, such that within each group, no rectangle can overlap another one. What is the minimum number of groups that we can partition the rectangles into? Constraints: 1 <= n <= 5000 1 <= length[i], breadth[i] <= 10^5 Examples: n = 5 length = [1, 2, 5, 4, 3] breadth = [3, 5, 2, 1, 4] Answer = 2 We can partition these rectangles into 2 groups, group 1 containing rectangles 1 and 4 (1 x 3, 4 x 1), and group 2 containing rectangles 2, 3 and 5 (2 x 5, 5 x 2, 3 x 4). [execution time limit] 4 seconds (py3) [input] array.integer length [input] array.integer breadth [output] integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to partition the given rectangles into groups such that no rectangle in a group can overlap another rectangle in the sam... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!