Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 28 | 29 | 30 | 31 |
Tags
- 플로이드와샬
- 백준
- MAP
- 코테준비
- String
- Dijkstra
- C++
- 프로그래머스
- 코딩테스트연습
- 정렬
- MySQL
- DP
- 다이나믹프로그래밍
- unordered_map
- substr
- 스택
- 다익스트라
- 알고리즘
- 문자열
- 최대공약수
- 참고 문헌 : MACHINE LEARNING 기계학습 _ 오일석
- 시스템콜
- 동적계획법
- 코테
- set
- vector
- sql고득점kit
- dfs
- 우선순위큐
- 리시프
Archives
- Today
- Total
YeJin's Footsteps
H-Index 본문
이 문제를 해결하는 가장 빠른 방법은 문제에 첨부된 위키백과를 참고하는 것이다.
"answer"는 citations 내에 없을 수도 있다.
문제 링크
https://programmers.co.kr/learn/courses/30/lessons/42747
코딩테스트 연습 - H-Index
H-Index는 과학자의 생산성과 영향력을 나타내는 지표입니다. 어느 과학자의 H-Index를 나타내는 값인 h를 구하려고 합니다. 위키백과1에 따르면, H-Index는 다음과 같이 구합니다. 어떤 과학자가 발표
programmers.co.kr
풀이 코드
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
int answer = 0;
sort(citations.begin(), citations.end());
int T=citations.size();
int cnt=0,h=citations[T-1];
h++;
while(h--){
for(int i=citations.size()-1; i>=0; i--){
if(citations[i]>=h) cnt++;
else break;
}
if(h<=cnt) {answer=h; break;}
cnt=0;
}
return answer;
}
Comments