` ````
```

Auto Saved.

Loading Question ...

- Total Accepted:
**89606** - Total Submissions:
**331985** - Difficulty:
**Hard** -
Contributor:
**LeetCode**

Given a set of *non-overlapping* intervals, insert a new interval into the intervals (merge if necessary).

You may assume that the intervals were initially sorted according to their start times.

**Example 1:**

Given intervals `[1,3],[6,9]`

, insert and merge `[2,5]`

in as `[1,5],[6,9]`

.

**Example 2:**

Given `[1,2],[3,5],[6,7],[8,10],[12,16]`

, insert and merge `[4,9]`

in as `[1,2],[3,10],[12,16]`

.

This is because the new interval `[4,9]`

overlaps with `[3,5],[6,7],[8,10]`

.

Subscribe to see which companies asked this question.

Show Similar Problems

(M) Merge Intervals
Have you met this question in a real interview?

Yes

No

When did you meet this question?

last week

last month

last 3 month

last 6 month

more than 6 months

other

Which company asked you this question?

Adobe

Aetion

Affirm

Airbnb

Alation

Alibaba

Amazon

AppDynamics

Apple

Arista

Baidu

Bank of America

BlackRock

Blend Labs

Blizzard

Bloomberg

Booking

Box

Bungie

Capital One

CareerBuilder

Cisco

Citadel

Coinbase

Concur

Conviva

Coupang

Coursera

CreditEase

CVTE

Dell

Deutsche Bank

DoorDash

Dropbox

Duolingo

EasyNet

eBay

Electronic Arts

EMC

Epic Systems

Equinix

Evernote

Expedia

Facebook

FactSet

Fitbit

Flipkart

Fortinet

FourSquare

FreeWheel

GoDaddy

Goldman Sachs

Google

GrabTaxi

Groupon

HBO

Hedvig

HomeAway

HTC

Huawei

Hulu

IBG

IBM

Indeed

InnovatureLabs

Intel

IXL

Jane Street

JPMorgan

Jump Trading

Lending Club

LinkedIn

LiveRamp

Loovee

Marvel

Matlab

McKesson

Microsoft

Morgan Stanley

NetEase

Nintendo

Nutanix

Nvidia

Oracle

Orbitz

Palantir

Paypal

Pinterest

Pocket Gems

Point72

Qualcomm

Qualtrics

Qumulo

Quora

Rackspace

Redfin

Rubrik

Salesforce

Samsung

SAP

ServiceNow

Sina

Snapchat

SoftwareOne

Sony

SoundHound

Square

Sumologic

SurveyMonkey

Symantec

Tableau

Tencent

Tesorio

TinyCo

Tradeshift

TripAdvisor

Twilio

Twitter

Two Sigma

Uber

Veritas

Visa

VMware

Walmart

Wealthfront

Whitepages

Works Applications

Yahoo

Yandex

Yelp

Zappos

Zenefits

Zillow

Zynga