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
- substr
- vector
- 시스템콜
- 코딩테스트연습
- 코테준비
- 최대공약수
- 플로이드와샬
- 우선순위큐
- MySQL
- 코테
- 정렬
- DP
- MAP
- Dijkstra
- 다이나믹프로그래밍
- sql고득점kit
- unordered_map
- dfs
- 동적계획법
- String
- 스택
- 문자열
- 백준
- C++
- 프로그래머스
- 다익스트라
- set
- 알고리즘
- 리시프
- 참고 문헌 : MACHINE LEARNING 기계학습 _ 오일석
Archives
- Today
- Total
YeJin's Footsteps
H-Index 본문
이 문제를 해결하는 가장 빠른 방법은 문제에 첨부된 위키백과를 참고하는 것이다.
"answer"는 citations 내에 없을 수도 있다.
문제 링크
https://programmers.co.kr/learn/courses/30/lessons/42747
풀이 코드
#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