https://leetcode.com/problems/h-index/description/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public:
int hIndex(vector<int>& citations) {
int n = citations.size();
sort(citations.begin(), citations.end());
int mx = 0;
for (int i = n - 1; i >= 0; i--) {
if (citations[i] >= n - i) mx = max(mx, n - i);
}
return mx;
}
};
Time Complexity: O(nlogn)
Space: O(1)
沒什麼想說的