A66830. 下面schedule函数的时间复杂度为( )。1 #include <algorithm>
单选题
知识点
题目描述
下面schedule函数的时间复杂度为( )。
1 #include <algorithm>
2 using namespace std;
3 struct activity {
4 int id, start, end;
5 };
6 bool compare(activity a, activity b) {
7 return a.end < b.end;
8 }
9 int schedule(int n, activity * p) {
10 sort(p, p + n, compare);
11 int cnt = 0, end = 0;
12 for (int i = 0; i < n; i++) {
13 if (p[i].start >= end) {
14 end = p[i].end;
15 cnt++;
16 }
17 }
18 return cnt;
19 }选项(单选)
答案解析
详细答案解析为会员权益,按每日次数查看。
开通 / 升级会员