aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/deadmarshal/cpp/ch-2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-207/deadmarshal/cpp/ch-2.cpp')
-rw-r--r--challenge-207/deadmarshal/cpp/ch-2.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-207/deadmarshal/cpp/ch-2.cpp b/challenge-207/deadmarshal/cpp/ch-2.cpp
new file mode 100644
index 0000000000..6af3160443
--- /dev/null
+++ b/challenge-207/deadmarshal/cpp/ch-2.cpp
@@ -0,0 +1,22 @@
+#include<iostream>
+#include<vector>
+
+int h_index(const std::vector<int> &vec)
+{
+ int ret{};
+ for(int i = 0; i < vec.size(); ++i)
+ if(i >= vec[i])
+ {
+ ret = i;
+ break;
+ }
+ return ret;
+}
+
+int main()
+{
+ std::cout << h_index({10,8,5,4,3}) << '\n';
+ std::cout << h_index({25,8,5,3,3}) << '\n';
+ return 0;
+}
+