← BlackRock Interview Insights

BlackRock·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

BlackRock Data Engineer interview with a classic interval merging problem. Pretty standard algorithmic screen, nothing too wild, but the edge cases will get you if you're not careful.

Questions Asked (1)

Q1

Given a sorted list of non-overlapping intervals and a new interval, insert the new interval into the list such that the result remains sorted and non-overlapping, merging where needed.

Algorithms & Data Structures
Author's notes

I jumped straight to coding and missed the overlap condition for a minute.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Walk through the intervals in three phases: first, add all intervals that end before the new interval starts; second, merge all intervals that overlap with the new interval by updating its start and end; third, add the remaining intervals. This linear scan approach is optimal because the input is already sorted and non-overlapping.

Pro tip: Explicitly state that the algorithm runs in O(n) time and O(n) space for the output, and mention that since the input is sorted, we avoid sorting and achieve linear time. Also, clarify that you're not modifying the input in place unless asked.

1. Clarify and confirm assumptions

Ask if the intervals are inclusive/exclusive, if the new interval can be empty, and if the result should be a new list or modified in place. Confirm that intervals are sorted by start time and non-overlapping.

2. Add intervals before the new interval

Iterate through the list and append all intervals whose end is less than the new interval's start. These intervals cannot overlap with the new interval.

3. Merge overlapping intervals

While the current interval's start is less than or equal to the new interval's end, update the new interval's start to the minimum of the two starts and its end to the maximum of the two ends. This merges all overlapping intervals.

4. Add the merged interval and remaining intervals

Append the merged new interval to the result, then append all remaining intervals from the list. Return the result.

5. Analyze complexity and edge cases

State that the time complexity is O(n) and space is O(n) for the output. Discuss edge cases: new interval before all, after all, overlapping multiple, or not overlapping any.

Key Points to Mention

  • Linear scan approach leveraging sorted input
  • Three-phase algorithm: before, merge, after
  • Time complexity O(n) and space O(n)
  • Edge cases: empty list, new interval at start/end, overlapping multiple intervals
  • In-place vs new list trade-off
  • Handling inclusive/exclusive boundaries

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