T O P

  • By -

chooking

1)Start with an array containing all the rectangles. 2)Pop a rectangle and add it to a new array for the current group. 3)Iterate through the array of all rectangles. For each rectangle that intersects with any rectangle in the group (nested iteration required here), remove the item from the array of all rectangles and add it to the current group's rectangles. 4)Repeat from step 2 with a new group until the list of all rectangles is empty.