Skip to content

Instantly share code, notes, and snippets.

@decagondev
Created April 23, 2025 21:12
Show Gist options
  • Save decagondev/671df6b780b06b7f71671887fd3c41e7 to your computer and use it in GitHub Desktop.
Save decagondev/671df6b780b06b7f71671887fd3c41e7 to your computer and use it in GitHub Desktop.

PROBLEM 3: Merge Intervals

Problem Statement

Given an array of intervals where intervals[i] = [start_i, end_i], merge all overlapping intervals.

Concepts Covered

  • Sorting
  • Interval Merging

Examples

Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]

Input: intervals = [[1,4],[4,5]]
Output: [[1,5]]

Starter Code

def merge(intervals: list[list[int]]) -> list[list[int]]:
    # Implement your solution here
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment