typedef struct node{
int left;
int right;
}bounds;
int cmp(const void* a,const void* b){
bounds* x=(bounds*)a;
bounds* y=(bounds*)b;
if(x->right > y->right ) return 1;
return -1;
}
int eraseOverlapIntervals(int** intervals, int intervalsSize, int* intervalsColSize) {
*intervalsColSize=intervalsSize;
bounds* b=(bounds*)malloc(sizeof(bounds)*intervalsSize);
for(int i=0;i<intervalsSize;i++){
b[i].left=intervals[i][0];
b[i].right=intervals[i][1];
}
qsort(b,intervalsSize,sizeof(bounds),cmp);
int sum=0;
long min=LONG_MIN;
for(int i=0;i<intervalsSize;i++){
if(b[i].left >= min){
sum++;
min=b[i].right;
}
}
return intervalsSize-sum;
}
标签:right,return,重叠,int,bounds,intervalsSize,intervalsColSize,区间,435
From: https://www.cnblogs.com/llllmz/p/18078718