Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Intervals

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Intervals

Merge Intervals

intermediatelayer I10 · Intervals5 tests

Given an array of intervals where intervals[i] = [start, end], merge every group that overlaps and return the resulting non-overlapping intervals.

  • The input is not sorted
  • Intervals that merely touch, such as [1,4] and [4,5], count as overlapping and merge into [1,5]
  • Return the merged intervals sorted by start
  • An empty input returns an empty array

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen