I have a list of rectangles. I need to find a list of lists in which all the overlapping rectangles are returned. For example, in a list of 7 rectangles, if 4 rectangles are overlapped and rest are separate then a list of lists should look like this:
[0]: r1, r2, r3, r4
[1]: r5
[2]: r6
[3]: r7
Again, it will create a chain. For example, if r1, and r2 are hitting and r2 and r3 are hitting and r1 and r4 are hitting then it will give the list[0].
Please concentrate again, it is only returning the grouped list of list and the returned list's count is not equal to the supplied list count.
I will only except elegant solution. That is, you should not use arrays to store intersection values. And it should be done with recursion.
It should be done in C#.
Thanks