프로그래머스 H-Index

조항주·2022년 4월 18일
0

algorithm

목록 보기
15/50
post-thumbnail

문제

https://programmers.co.kr/learn/courses/30/lessons/42747

코드

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

using namespace std;

bool compare(int a, int b) { return a > b; }

int solution(vector<int> citations) {
    sort(citations.begin(), citations.end(), compare);

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

풀이

이 문제는 문제를 이해하는게 제일 어려웠어요 H-index란 개념을 처음 들어본건 당연한거고 이게 또 실제로 있는 개념이더라고요 https://en.wikipedia.org/wiki/H-index
아무튼 문제만 이해를 하면 구현자체는 어렵지 않습니다 뽀인트는 h값이 꼭 citations안에 있지는 않다는 겁니다 몇번을 읽어도 적응이 안되네요

0개의 댓글