Tag: insertnewinterval
-
Data Structures & Algorithms in Java – Intervals- Insert new interval
Problem: Given an array of sorted intervals , insert a new interval at the correct position. If the new interval overlaps with the previous interval merge them into one interval and do the same for the subsequent intervals after the new interval. For example, Given the below array of intervals: [[1,2] ,[3,5],[6,7],[8,10],[12,16]] and the new…