Coding Test/Programmers
[Programmers] (정렬) Lv 2. H-Index
song.ift
2024. 10. 17. 02:46
https://school.programmers.co.kr/learn/courses/30/lessons/42747
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
//24.10.17
sort(citations.rbegin(), citations.rend());
int h = citations.front();
int idx = 0, cnt = 0;
while(h)
{
if (citations[idx] >= h)
{
++cnt;
++idx;
}
if (h <= cnt) break;
--h;
}
return h;
}
[level 2] Title: H-Index, Time: 0.07 ms, Memory: 4.13 MB -BaekjoonHub · developeSHG/Algorithm-Baekjoon_Programmers@a39ae89
developeSHG committed Oct 16, 2024
github.com