区间扫描
软件园里卖煎饼
以文载意,以理铸心
展开
-
leetcode1024. 视频拼接
解题思路 按照左端点升序右端点降序的顺序先排序 以当前能到达的最大值作为条件,找到目前能剪辑的最长时长 代码 class Solution { public int videoStitching(int[][] clips, int time) { Arrays.sort(clips,new Comparator<int[]>() { @Override public int compare(int[] o1, int[]原创 2021-07-16 16:06:46 · 96 阅读 · 0 评论 -
leetcode1288. 删除被覆盖区间
解题思路 按照左端点升序右端点降序的顺序先排序 在判断情况 1.覆盖 2.相交 3.无交点 代码 class Solution { public int removeCoveredIntervals(int[][] intervals) { List<int[]> arrList = new ArrayList<>(); int n = intervals.length; for(int i=0;i<n;i++){原创 2021-07-16 16:06:05 · 72 阅读 · 0 评论 -
leetcode56. 合并区间
解题思路 按照左端点升序右端点降序的顺序先排序 区间扫描并记录坐标 代码 class Solution { public int[][] merge(int[][] intervals) { Arrays.sort(intervals,new Comparator<int[]>() { @Override public int compare(int[] o1, int[] o2) { //左原创 2021-07-16 16:05:31 · 47 阅读 · 0 评论 -
leetcode986. 区间列表的交集
解题思路 扫描并判断情况 代码 class Solution { public int[][] intervalIntersection(int[][] firstList, int[][] secondList) { int n1 = firstList.length,n2 = secondList.length; if(n1==0 || n2==0){ return new int[0][0]; } List原创 2021-07-16 16:04:56 · 37 阅读 · 0 评论