Sweep Line & Interval
思路:
Template for Point
class Point{
int time;
int flag; // 1=start, 0=end
Point(int time, boolean flag){
this.time = time;
this.flag = flag;
}
public static Comparator<Point> pointComparator = new Comparator<Point>() {
public int compare(Point p1, Point p2){
// 如果时间一致,如果两个都是start或都是end,那么它两相等。如果p1是start而p2是end,那么p1 > p2
if (p1.time == p2.time) return p1.flag - p2.flag;
else return p1.time - p2.time;
}
}Reference
Last updated