프로그래머스
1. Python
def solution(citations):
citations = sorted(citations)
l = len(citations)
for i in range(l):
if citations[i] >= l-i:
return l-i
return 0
2. C++
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
sort(citations.begin(), citations.end(), greater<>());
int i = 0;
while (i + 1 <= citations[i]) {
i++;
}
return i;
}
3. JavaScript
function solution(citations) {
citations = citations.sort((a, b) => b - a);
let i = 0;
while (i + 1 <= citations[i]) {
i++;
}
return i;
}