https://school.programmers.co.kr/learn/courses/30/lessons/42747
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
32
33
34
35
36
|
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool CheckQuotedCount(int number, vector<int> citations)
{
int quotedCount = 0;
for (int i = 0; i < citations.size(); i++)
{
if (citations[i] >= number)
quotedCount++;
}
//H-Index => 인용된 개수가 number 이상일 때
return quotedCount >= number;
}
int solution(vector<int> citations) {
int answer = 0;
int maxQuotedCount = *max_element(citations.begin(), citations.end());
//최대 인용 횟수부터 내려가면서 검사
for (int i = maxQuotedCount; i >= 0; i--)
{
if (CheckQuotedCount(i, citations))
{
answer = i;
break;
}
}
return answer;
}
|
cs |
'프로그래머스 - 내 풀이 > 프로그래머스 Lv2' 카테고리의 다른 글
프로그래머스/괄호 회전하기 (0) | 2023.04.14 |
---|---|
프로그래머스/카카오프렌즈 컬러링북 (0) | 2022.12.12 |
프로그래머스 / KAKAO BLIND RECRUITMENT / 오픈채팅방 (0) | 2022.02.11 |
프로그래머스 / 월간 코드 챌린지 시즌1 / 삼각 달팽이도움말 (0) | 2021.04.07 |
프로그래머스 / Summer/Winter Coding(~2018) / 영어 끝말 잇기 (0) | 2020.09.08 |