Given non-overlapping sorted intervals and a new interval, insert the new interval and merge if necessary. Return the resulting intervals.
Input: intervals = [[1,3],[6,9]], newInterval = [2,5] Output: [[1,5],[6,9]]
Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] Output: [[1,2],[3,10],[12,16]]
Jnaneshwara Reddy Satti
Builder · ClearCode
Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕
If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.