Skip to content

Commit

Permalink
이슈 #413에서 솔루션 추가
Browse files Browse the repository at this point in the history
actions-user committed Dec 2, 2024
1 parent 23cbc76 commit a0a75b5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Programmers/H-Index.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <vector>
#include <algorithm>

using namespace std;

int solution(vector<int> citations) {
sort(citations.begin(), citations.end(), greater<int>());

int h_index = 0;

for (int i = 0; i < citations.size(); i++) {
if (citations[i] >= i + 1) {
h_index = i + 1;
}
else {
break;
}
}

return h_index;
}

0 comments on commit a0a75b5

Please sign in to comment.