Merge Intervals

In this blog post, I will be giving a brief description about another pattern that is very important for technical interviews. The pattern is called merge intervals.

This pattern is used to solve problems that involve intervals, overlapping items that need to be merged etc. In most of the problems that involve intervals, you either need to find overlapping intervals or merge intervals if they overlap.

Problem that include Merge Intervals:

Example 1:

Example 2:

Given two intervals [A and B], there can be six different ways the two intervals can relate to each other:


Identification of Merge Intervals:

We can identify if the problem uses merge intervals pattern by following ways;

  • If a question asks us to produce a list with only mutually exclusive intervals
  • If a question has a term “overlapping intervals” in it.




Student at Flatiron School

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store