https://oj.leetcode.com/problems/insert-interval/ 给出有序的区间来,再插入进去一个,也就是区间合并。 刚开始确立了几个思路,看要插入的区间的start和end分别位于什么位置。区分是在空闲处还是在一个区间里面,并且还要判断跨越了几个区间,并且要进行数组元素的后移之类的。写了代码比较麻烦,于是想新的思路。如
Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. Example 2:Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16]. This is because the new interval [4,9] overlaps with [3,5],[6,7],[8,...