ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
int minRemoval(vector &intervals) { sort(begin(intervals), end(intervals), [&](vector& a,vector& b){ return a[1] < b[1]; }); int n = intervals.size(); int count = 0; int endInterval = intervals[0][1]; for(int i = 1; i < n; ++i){ if(endInterval > intervals[i][0]){ count += 1; }else{ endInterval = intervals[i][1]; } } return count; }
int minRemoval(vector &intervals) {
sort(begin(intervals), end(intervals), [&](vector& a,vector& b){
return a[1] < b[1];
});
int n = intervals.size();
int count = 0;
int endInterval = intervals[0][1];
for(int i = 1; i < n; ++i){
if(endInterval > intervals[i][0]){
count += 1;
}else{
endInterval = intervals[i][1];
}
}
return count;
}