class Solution { public: int hIndex(vector& citations) { sort(citations.begin(), citations.end()); int j = 0; for(int i=citations.size()-1;i>=0;i--) { j++; if(citations[i] == j) return j; if(citations[i] < j) return j-1; } return j; } };