문제 이해가 안가서 시간이 좀 걸렸다.

구현은 쉬웠던 문제.

#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)
            return i;
}

+ Recent posts