Recent Posts
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Today
Total
관리 메뉴

Try

[Programmers/C++] H-Index 본문

Algorithm/Programmers

[Programmers/C++] H-Index

HAS3ONG 2019. 4. 7. 19:08

출처

https://has3ong.tistory.com/manage/newpost/?type=post&returnURL=%2Fmanage%2Fposts

 

TISTORY

나를 표현하는 블로그를 만들어보세요.

www.tistory.com

소스

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(vector<int> citations) {
    int answer = 0;
    sort(citations.begin(), citations.end());
    
    reverse(citations.begin(), citations.end());

    for (int i = 0; i < citations.size(); i++)
    {
        if (i + 1 > citations[i])
        {
            answer = i;
            return answer;
        }
    }
}
Comments