Coding Test/Programmers
[Programmers] (정렬) Lv 2. H-Index
song.ift
2024. 10. 17. 02:46
https://school.programmers.co.kr/learn/courses/30/lessons/42747
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
//24.10.17
sort(citations.rbegin(), citations.rend());
int h = citations.front();
int idx = 0, cnt = 0;
while(h)
{
if (citations[idx] >= h)
{
++cnt;
++idx;
}
if (h <= cnt) break;
--h;
}
return h;
}