Skip to main content

← Searching and sorting

Merge meeting times

medium

The first line has n. Each of the next n lines has a start and end time. Merge the ones that overlap or touch and print the merged ranges in order, one "start end" per line.

Example 1: input

4
1 3
2 6
8 10
15 18

Output

1 6
8 10
15 18

Example 2: input

2
1 4
4 5

Output

1 5

Plus 2 hidden tests when you check your answer.

Your solution

Read from standard input and print the answer. Run it on the examples as often as you like, then check it against every test.

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.