leetcode57.插入区间——学习笔记

题目:力扣icon-default.png?t=M1H3https://leetcode-cn.com/problems/insert-interval/


class Solution {
    public int[][] insert(int[][] intervals, int[] newInterval) {
        int[][] finalInterval = new int[intervals.length+1][2];
        int count = 0;
        while(count<=intervals.length){
            if(count path = new ArrayList();
        int left = 0;
        int right = 0;
        while(right=R){
            return;
        }
        int left = L;
        int right = R;
        int pivot = intervals[left][0];
        while(left=pivot){
                right--;
            }
            if(leftpivot
                int temp0 = intervals[right][0];
                int temp1 = intervals[right][1];
                intervals[right][0] = intervals[left][0];
                intervals[right][1] = intervals[left][1];
                intervals[left][0] = temp0;
                intervals[left][1] = temp1;
            }
            if(left>=right){
                intervals[left][0] = pivot;
            }
        }
        quickSort(intervals,L,right-1);
        quickSort(intervals,right+1,R);
    }
}

 leetcode57.插入区间——学习笔记_第1张图片


思路:这题跟 leetcode56.合并区间唯一的区别就是增加了一个数组,今天就稍稍偷个懒,直接将新的数组添进去,然后利用上一题的解法直接求解。

你可能感兴趣的:(Leetcode练习,学习,leetcode,java)