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