Intermediatecoding Verified
Insert a new interval into a sorted list of non-overlapping intervals, merging where necessary.
ReportedSource: GeeksforGeeks interview experience: Infosys Specialist Programmer L2 off-campus
Quick answerFree
Copy intervals ending before the new start, merge all overlapping ones into the new interval (min start, max end), append it, copy the rest. O(n).
Detailed answer· 85 words
Interview PrepUnlock the full answer with Interview Prep
Get a 85-word model answer and a runnable reference solution, plus 61 more DSA questions.
Also in Pro (₹499 / 90 days).
Reference solution· runs in the browser sandbox
Interview PrepUnlock with Interview Prep
+ 61 more DSA questions in Interview Prep, each with the full answer.