Intervals & Overlap Scheduling

Data Structures

Managing overlapping timelines, meeting rooms, and range merges

41 problems·3 Easy·27 Medium·11 Hard
Pattern Study Guide & Cheat Sheet
▼

Sort ranges by start (or end) time so overlapping relationships can be resolved linearly by comparing adjacent pairs.

Core Invariant: Once sorted by start time (`start_i <= start_j`), interval J overlaps with interval I if and only if `start_j <= end_i`. When overlapping, merged end is `max(end_i, end_j)`.

Recognize it (Keywords & Signals)
  • Merge overlapping intervals
  • Insert interval into sorted non-overlapping list
  • Non-overlapping intervals (erase minimum overlaps)
  • Meeting rooms (minimum conference rooms needed / can attend all)
When NOT to use

Intervals cannot be sorted or endpoints are infinite/continuous without discrete ordering.

How to solve (Step-by-step)
  1. 1.Sort intervals by start time: `intervals.sort(key=lambda x: x[0])`.
  2. 2.Initialize `merged = [intervals[0]]`.
  3. 3.Iterate through subsequent intervals `[curr_start, curr_end]`.
  4. 4.If `curr_start <= merged[-1][1]`: overlap exists! Update `merged[-1][1] = max(merged[-1][1], curr_end)`.
  5. 5.Else: no overlap. Append `[curr_start, curr_end]` to `merged`.
  6. 6.Return `merged`.
Watch for (Interview Traps)
  • Touching endpoints edge case: verify if `[1, 2]` and `[2, 3]` overlap (`start <= last_end` vs `start < last_end`)
  • Forgetting `max(last_end, end)`: the previous interval might already be longer than current
  • Meeting Rooms II: sorting only by start time without tracking end times with a heap
Merge Overlapping Intervals
def merge_intervals(intervals: list[list[int]]) -> list[list[int]]:
    if not intervals:
        return []
        
    # Sort primarily by start time
    intervals.sort(key=lambda x: x[0])
    merged = [intervals[0]]
    
    for start, end in intervals[1:]:
        last_end = merged[-1][1]
        
        if start <= last_end:
            # Overlapping intervals: merge by taking the max end
            merged[-1][1] = max(last_end, end)
        else:
            # Non-overlapping: append as separate interval
            merged.append([start, end])
            
    return merged
Cost
O(n log n) dominated by initial sort · O(n) for output list (Linear O(n) pass after the O(n log n) sort.)
Canonical problems
#56 Merge Intervals: Standard sort by start time and extend ends
#57 Insert Interval: Add before overlap, merge during overlap, append after overlap
#435 Non-overlapping Intervals: Greedy: sort by end time to keep intervals that finish earliest
#253 Meeting Rooms II: Min-heap of end times tracks currently occupied rooms
Medium·124 companies·Max freq 100%·Acc 52.3%
BroadcomCoupaDiscovery+121
Medium·51 companies·Max freq 100%·Acc 52.7%
SnapSnapSplunk+48
Medium·23 companies·Max freq 90%·Acc 57.4%
GrammarlyVerkadaZoho+20
Medium·19 companies·Max freq 76%·Acc 45.5%
TescoMongoDBPhonePe+16
Hard·15 companies·Max freq 63%·Acc 0.5%
TikTokPinterestNutanix+12
Hard·13 companies·Max freq 75%·Acc 73.0%
AirbnbCitadelIntuit+10
Easy·13 companies·Max freq 60%·Acc 59.5%
NeetCode 150NeetCode 150Blind 75+10
Medium·12 companies·Max freq 100%·Acc 73.1%
MixpanelVerkadaMeta+9
Medium·12 companies·Max freq 89%·Acc 56.4%
CareemZeptoLyft+9
Medium·12 companies·Max freq 75%·Acc 58.3%
UberFlexportIntuit+9
Medium·10 companies·Max freq 100%·Acc 0.6%
LivspaceExpediaBarclays+7
Hard·8 companies·Max freq 88%·Acc 44.9%
SoFiPhonePeLinkedIn+5
Medium·7 companies·Max freq 100%·Acc 64.0%
razorpayGrammarlyJPMorgan Chase+4
Medium·7 companies·Max freq 88%·Acc 63.6%
Walmart LabsAdobeIBM+4
Hard·7 companies·Max freq 63%·Acc 59.9%
General MotorsMetaInfosys+4
Medium·6 companies·Max freq 61%·Acc 60.0%
StripeAmazonGoogle+3
Easy·6 companies·Max freq 38%·Acc 54.6%
MicrosofttcsGoogle+3
Easy·5 companies·Max freq 100%·Acc 57.9%
Riot GamesJane Streettcs+2
Hard·5 companies·Max freq 95%·Acc 31.8%
SprinklrAmazonBloomberg+2
Hard·5 companies·Max freq 60%·Acc 0.5%
NeetCode 150NeetCode 150Google+2
Medium·4 companies·Max freq 88%·Acc 52.8%
VerilyAndurilGoogle+1
Hard·4 companies·Max freq 63%·Acc 36.1%
LinkedInDatabricksUber+1
Medium·4 companies·Max freq 25%·Acc 56.1%
MicrosoftAmazonGoogle+1
Medium·4 companies·Max freq 25%·Acc 0.5%
GoogleMicrosoftAmazon+1
Hard·3 companies·Max freq 100%·Acc 52.2%
DirectiMedia.netMedia.net
Medium·3 companies·Max freq 86%·Acc 0.6%
SprinklrAmazonGoogle
Medium·3 companies·Max freq 75%·Acc 37.9%
InfosysNetAppGoogle
Medium·3 companies·Max freq 30%·Acc 63.3%
AppleGoogleAmazon
Hard·3 companies·Max freq 25%·Acc 0.7%
AmazonMicrosoftGoogle
Medium·3 companies·Max freq 25%·Acc 0.7%
AmazonGoogleMeta
Hard·3 companies·Max freq 13%·Acc 60.3%
GoogleAmazonBloomberg
Medium·2 companies·Max freq 100%·Acc 0.4%
American ExpressGoogle
Medium·2 companies·Max freq 100%·Acc 48.1%
WayveTuSimple
Medium·2 companies·Max freq 50%·Acc 44.4%
AgodaSalesforce
Medium·2 companies·Max freq 30%·Acc 40.1%
UberGoogle
Medium·2 companies·Max freq 13%·Acc 49.5%
MicrosoftGoogle
Medium·1 companies·Max freq 75%·Acc 50.1%
DE Shaw
Medium·1 companies·Max freq 25%·Acc 67.3%
Google
Hard·1 companies·Max freq 25%·Acc 72.0%
Google
Medium·1 companies·Max freq 25%·Acc 49.1%
Google
Medium·1 companies·Max freq 17%·Acc 46.1%
Google
41 displayed (of 41 matching)Filtered: All Companies

Top Companies Testing Intervals & Overlap Scheduling

Browse company-specific interview problem lists and recency breakdowns:

Explore All 22 DSA Coding Patterns

Master core algorithmic patterns tested in FAANG & Big Tech coding interviews.

Patterns Hub

Intervals & Overlap Scheduling frequently asked questions

What is the Intervals & Overlap Scheduling pattern in coding interviews?

Managing overlapping timelines, meeting rooms, and range merges It is categorized under Data Structures and features 41 curated interview problems across Easy (3), Medium (27), and Hard (11) difficulties.

Which tech companies frequently test Intervals & Overlap Scheduling?

Companies frequently asking Intervals & Overlap Scheduling questions include Google, Amazon, Microsoft, Bloomberg, Meta, NeetCode 150.

How do I master the Intervals & Overlap Scheduling pattern?

Start by studying the algorithmic strategy and template code, then practice Easy and Medium problems before attempting Hard problems under timed conditions.