home/productivity/task-merge-overlapping-intervals

Task: merge overlapping intervals

GPTClaudeDeepSeek··777 copies·updated 2026-07-14
task-merge-overlapping-intervals.prompt
# Task: merge overlapping intervals

## Deliverable

Implement `merge_intervals(intervals: list[list[int]]) -> list[list[int]]` in
`merge_intervals.py`.

## Spec

- Each interval is `[start, end]` with `start <= end` (integers).
- Merge all overlapping or **touching** intervals (e.g. `[1,2]` and `[2,3]` → `[1,3]`).
- Return merged intervals sorted by start ascending.
- Empty input → `[]`.
- Do not mutate the caller's list (return a new list).
- Invalid shapes are out of scope (tests only pass well-formed intervals).

## Constraints

- Stdlib only; edit only the starter tree; no hidden-test edits.

## Done means

Function matches the spec; note verification.

when to use it

Community prompt sourced from the open-source GitHub repo TinkerandScribe/gxp (MIT). A "Task: merge overlapping intervals" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

productivitycommunitydeveloper

source

TinkerandScribe/gxp · MIT