← BlackRock Interview Insights

BlackRock·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

BlackRock Data Engineer interview with a coding problem on interval merging. Pretty standard algorithmic round, nothing too wild, but the problem has enough edge cases to trip you up if you're not careful.

Questions Asked (1)

Q1

You're given a sorted list of non-overlapping intervals and a new interval. Insert the new interval into the list, merging any overlaps, so the result stays sorted and non-overlapping.

Algorithms & Data Structures
Author's notes

Classic interval problem but I always forget to handle the edge cases cleanly under pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a linear scan to handle three phases: intervals completely before the new interval, intervals that overlap and need merging, and intervals completely after. Maintain the sorted order by appending intervals in the correct sequence, merging overlaps by updating the new interval's start and end. This yields an O(n) time and O(n) space solution, which is optimal for this problem.

Pro tip: Clarify edge cases upfront, such as an empty list, the new interval being before all existing intervals, or after all of them. Also, mention that if the list were a balanced BST, insertion could be O(log n), but for an array-based list, O(n) is expected.

1. Clarify and confirm assumptions

Restate the problem to ensure understanding: the input list is sorted and non-overlapping, and the output must also be sorted and non-overlapping. Ask about edge cases like empty list or intervals with equal boundaries.

2. Handle intervals before the new interval

Iterate through the list and add all intervals that end before the new interval starts. These intervals do not overlap and come before the new interval in sorted order.

3. Merge overlapping intervals

While the current interval starts before or at the new interval's end, merge them by updating the new interval's start to the minimum of the two starts and its end to the maximum of the two ends.

4. Add the merged interval and remaining intervals

Insert the merged new interval into the result, then add all remaining intervals that come after it. Return the result list.

5. Analyze complexity and test

State that the time complexity is O(n) and space complexity is O(n) for the output. Walk through a few test cases, including edge cases, to verify correctness.

Key Points to Mention

  • Linear scan approach with three phases: before, merging, after.
  • Merging condition: new interval overlaps if its start <= current interval's end and its end >= current interval's start.
  • Time complexity O(n) and space complexity O(n) due to output list.
  • Edge cases: empty input list, new interval before all, new interval after all, new interval completely covering multiple intervals.
  • Maintaining sorted order by appending intervals in the correct sequence.
  • Alternative data structures (e.g., balanced BST) for different trade-offs, but not necessary for this problem.

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