目录
贪心
- 找到贪心策略,使得:局部最优解-->整体最优解
刷题
252. 会议室(P)
253. 会议室 II (P)
#define MAX 1000001
int minMeetingRooms(int** intervals, int intervalsSize, int* intervalsColSize) {
int diff[MAX] = {0};
for (int i = 0; i < intervalsSize; i++) {
diff[intervals[i][0]] += 1;
diff[intervals[i][1]] -= 1;
}
int ret = 0;
long sum = 0;
for (int i = 0; i < MAX; i++) {
sum += diff[i];
ret = fmax(sum, ret);
}
return ret;
}