力扣274. H 指数
题目:【https://leetcode.cn/problems/h-index/?envType=study-plan-v2&envId=top-interview-150】
其实就是理解成两个维度,找到两个维度在相互制衡情况下的公共最大值。
1 class Solution { 2 public: 3 int hIndex(vector<int>& citations) { 4 sort(citations.begin(), citations.end()); 5 int n = citations.size(); 6 for (int i = 0; i < n; ++i) { 7 if (citations[i] >= n - i) 8 return n - i; 9 } 10 return 0; 11 } 12 };