[프로그래머스] H-Index - (정렬) c++

ha·2022년 1월 10일
0

프로그래머스

목록 보기
7/21

정렬 풀이

citat => 6 5 3 1 0
index => 0 1 2 3 4
if(citations[i]>=i+1) answer=i+1;

int solution(vector<int> citations) {
    int answer = 0;
    sort(citations.begin(),citations.end(),greater<int>());
    for(int i=0;i<citations.size();i++){
        if(citations[i]>=i+1) answer=i+1;
    }
 
    return answer;
}

0개의 댓글