프로그래머스 - hIndex

phoenixKim·2021년 8월 14일
0

소스코드

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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


-> 코드 실행은 맞았다. 다른방법으로 접근하자.

profile
🔥🔥🔥

0개의 댓글

관련 채용 정보