Merge Intervals (Function)

PHP Hard 7 views
Back to Questions

Problem Description

Given n intervals, merge overlaps and print the merged intervals sorted by start.

Input Format

First n. Next n lines l r.

Output Format

First line m. Next m lines merged.

Sample Test Case

Input:
4 1 3 2 6 8 10 9 12
Output:
2 1 6 8 12

Constraints

n

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev