From a0a75b5d3269f0c93c5f4e5894827ebc6dc9b49b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 2 Dec 2024 17:59:05 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=8A=88=20#413=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=86=94=EB=A3=A8=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/H-Index.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Programmers/H-Index.cpp diff --git a/Programmers/H-Index.cpp b/Programmers/H-Index.cpp new file mode 100644 index 0000000..92618c7 --- /dev/null +++ b/Programmers/H-Index.cpp @@ -0,0 +1,21 @@ +#include +#include + +using namespace std; + +int solution(vector citations) { + sort(citations.begin(), citations.end(), greater()); + + 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; +} \ No newline at end of file