https://leetcode.com/problems/h-index/
class Solution { public: int hIndex(vector<int>& citations) { priority_queue<int> pq; for(int i=0;i<citations.size();i++){ pq.push(citations[i]); } int pages=0; while(!pq.empty()){ int cur = pq.top(); pq.pop(); pages++; // 在取下一个值时候先判定是否为空 if(cur >= pages && (pq.empty() || pages >= pq.top())) return pages; } return 0; } };