← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Meta SWE coding round, got a interval merging problem that looked straightforward but had a few edge cases that tripped me up a bit.

Questions Asked (1)

Q1

Given two separately sorted lists of intervals, merge them into a single list with no overlapping intervals.

Algorithms & Data Structures
Author's notes

My first instinct was to just concatenate both lists and run a standard merge intervals pass on the combined result.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the input lists are each sorted and non-overlapping, then use a two-pointer technique to merge them in O(n+m) time, similar to merging two sorted arrays. While merging, maintain the last interval in the result and merge it with the next interval if they overlap.

Pro tip: Mention that this is a variation of the classic merge intervals problem and that the sorted property allows linear time; also discuss how you would handle edge cases like empty lists or intervals that touch at endpoints.

1. Clarify and Confirm

Ask if the intervals within each list are sorted by start time and non-overlapping, and confirm the definition of overlap (e.g., whether [1,2] and [2,3] are considered overlapping).

2. Plan the Two-Pointer Merge

Initialize pointers for both lists and an empty result list. At each step, pick the interval with the smaller start time from the two lists and append it to the result, merging with the last interval if they overlap.

3. Implement the Merge Logic

While both pointers are within bounds, compare the start times. If the chosen interval overlaps with the last interval in the result, merge them by updating the end time; otherwise, append it. Then advance the corresponding pointer.

4. Handle Remaining Intervals

After one list is exhausted, append the remaining intervals from the other list, merging with the last result interval if necessary.

5. Analyze Complexity and Edge Cases

State that the time complexity is O(n+m) and space is O(n+m) for the output. Discuss edge cases: empty lists, single interval, all intervals overlapping, and intervals that just touch.

Key Points to Mention

  • Two-pointer technique for merging sorted lists
  • Overlap condition: next.start <= current.end (or < depending on definition)
  • Merging by updating the end time to max(current.end, next.end)
  • Time complexity O(n+m) and space complexity O(n+m)
  • Handling edge cases: empty lists, single interval, touching intervals
  • Comparison to merging two sorted arrays and the merge intervals problem

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.