본문 바로가기
Algorithm

[프로그래머스] 42747번 H-Index C++

by SoyeonCha 2024. 11. 13.

문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/42747

 

 

메모

 

 

맞힌 코드

#include <bits/stdc++.h>

using namespace std;

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