Facebook | Merge two interval lists

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2016-06-29Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given A and B two interval lists, A has no overlap inside A and B has no overlap inside B. Write the function to merge two interval lists, output the result with no overlap. Ask for a very efficient solution.

A naive method can combine the two lists, and sort and apply merge interval in LeetCode, but is not efficient enough.

For example,
A: [1,5], [10,14], [16,18]
B: [2,6], [8,10], [11,20]

Output [1,6], [8, 20]

Comments