标签:rri png max 间隔 size begin csharp list i++
2018-09-07 09:03:14
一、Merge Intervals
问题描述:
问题求解:
public List<Interval> merge(List<Interval> intervals) { List<Interval> res = new ArrayList<>(); if (intervals.size() == 0) return res; intervals.sort(new Comparator<Interval>() { @Override public int compare(Interval o1, Interval o2) { return o1.start - o2.start; } }); int begin = intervals.get(0).start; int end = intervals.get(0).end; for (int i = 1; i < intervals.size(); i++) { if (end < intervals.get(i).start) { res.add(new Interval(begin, end)); begin = intervals.get(i).start; end = intervals.get(i).end; } end = Math.max(end, intervals.get(i).end); } res.add(new Interval(begin, end)); return res; }
标签:rri png max 间隔 size begin csharp list i++
原文地址:https://www.cnblogs.com/TIMHY/p/9602549.html