Help Yourself

I’m trying to solve this problem right now, but I’m struggling to understand what the problem is asking.

Define the union of a set of segments to be the set of all x that are contained within at least one segment. Define the complexity of a set of segments to be the number of connected regions represented in its union.

connected regions

I don’t really understand what this means…

There’s a sample explanation. Help yourself!

1 Like

The thing I’m confused about is:

{[1, 2], [4, 5]}

Would the answer to this be 1 or 2?

{[1, 3], [2, 4]}

Would the answer to this be 1 or 2?

The definition in the problem statement seems pretty unambiguous to me, but if you’re still unsure and you have multiple interpretations that pass the sample input you could always try submitting and seeing if you pass test cases 2-3.