← Meta Interview Insights

Meta·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Meta SWE coding round, one meaty interval problem that sounds straightforward until you actually have to think about edge cases under pressure.

Questions Asked (1)

Q1

Given two sorted lists of non-overlapping closed intervals, merge them into a single sorted list representing their union. You need to explain how you handle touching boundaries like [1,3] and [3,5], empty inputs, and invalid intervals where start exceeds end. Also state the time and space complexity and walk through an O(m+n) two-pointer solution.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The core merge logic clicked pretty fast for me, two pointers advancing through both lists, pick the smaller start, extend the end greedily.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying edge cases and assumptions, then outline the two-pointer merge algorithm, emphasizing how to handle touching boundaries and invalid intervals. Conclude with complexity analysis and a brief walkthrough of the algorithm.

Pro tip: Explicitly state your assumptions about interval validity and boundary touching, and ask the interviewer if they want you to handle invalid intervals by skipping or throwing an error. This shows attention to detail and proactive communication.

1. Clarify requirements and edge cases

Ask about handling of empty inputs, invalid intervals (start > end), and whether touching intervals like [1,3] and [3,5] should be merged. Confirm if the output should be sorted and non-overlapping.

2. Outline the two-pointer approach

Explain that you'll use two pointers, one for each list, to iterate through intervals in sorted order. At each step, pick the interval with the smaller start, and merge if it overlaps or touches the last interval in the result.

3. Detail the merge logic

Describe how to check for overlap: if the current interval's start <= last merged interval's end, merge by updating the end to max of both ends. For touching boundaries, treat as overlapping if start == end.

4. Handle invalid intervals

Decide on a strategy: either skip invalid intervals or throw an error. Mention that you'll assume inputs are valid unless specified otherwise, but you can add a check.

5. Analyze complexity and walk through example

State that time complexity is O(m+n) and space is O(m+n) for the output. Walk through a small example, including edge cases, to demonstrate correctness.

Key Points to Mention

  • Two-pointer technique for merging sorted lists in linear time
  • Handling touching boundaries: merge if start <= last_end (including equality)
  • Empty input handling: return the other list or empty list as appropriate
  • Invalid interval handling: skip or error, depending on requirements
  • Time complexity O(m+n) and space complexity O(m+n) for output
  • Maintaining sorted order and non-overlapping property in the result

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