ARST打卡第114周[114/521]

Algorithm

lc274-H指数

简单的思路是先排序再从大到小遍历,但是计数排序更佳
可以看详细题解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Solution {
public:
int hIndex(vector<int>& citations) {
int n = citations.size(), tot = 0;
vector<int> counter(n + 1);
for (int i = 0; i < n; i++) {
if (citations[i] >= n) {
counter[n]++;
} else {
counter[citations[i]]++;
}
}
for (int i = n; i >= 0; i--) {
tot += counter[i];
if (tot >= i) {
return i;
}
}
return 0;
}
};

Review

Samba codebase organization

Tips

linux设置动态库搜索路径三种方式

Share

极客时间-投资第一课