Notice
Recent Posts
Recent Comments
-
[프로그래머스] 레벨 2 - H-Index 본문
대학원때 논문쓰면서 H-index를 잘 몰랐는데 어쩌다 이 문제로 잘 알게됐다.
https://programmers.co.kr/learn/courses/30/lessons/42747
주어진 인용벡터를 내림차순하고, 가장 큰 수인 [0]번째 부터 h로 지정해 계속 내려오면서 h번 이상 인용된 논문의 수와 h보다 적게 인용된 논문의 수가 h이하라면 h가 H-Index라는 것이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int solution(vector<int> citations) {
sort(citations.begin(), citations.end(), greater<int>());
int maxval = citations[0];
int answer = 0;
for(int h=maxval; h>=0; h--){
int over_h = 0, less_h = 0;
for(int i=0; i<citations.size(); i++){
int cur_paper = citations[i];
if(cur_paper >= h) over_h++;
else {
less_h = citations.size()-i;
break;
}
}
if(over_h >= h && less_h <= h) {
answer = h;
break;
}
}
return answer;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'1-4. 프로그래머스' 카테고리의 다른 글
[프로그래머스] 레벨 2 - 타겟 넘버 (0) | 2020.02.07 |
---|---|
[프로그래머스] 레벨 2 - 카펫 (0) | 2020.02.07 |
[프로그래머스] 레벨 2 - 소수 찾기 (0) | 2020.02.07 |
[프로그래머스] 레벨 2 - 전화번호 목록 (0) | 2020.02.07 |
[프로그래머스] 레벨 2 - 숫자 야구 (0) | 2020.02.06 |
Comments