Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

intervals =
newInterval =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Add interval into sorted non-overlapping list and merge overlaps.

Approach

  • Add all intervals ending before new interval starts.
  • Merge all overlapping intervals into [s,e].
  • Append the merged interval.
  • Append the remaining intervals.
Code
Loading...
Complexity
Time: O(n)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Add interval into sorted non-overlapping list and merge overlaps.

Approach

  • Add all intervals ending before new interval starts.
  • Merge all overlapping intervals into [s,e].
  • Append the merged interval.
  • Append the remaining intervals.
Code
Loading...
Complexity
Time: O(n)
Space: O(n)