diff --git a/homework/max-of-vector/maxOfVector.hpp b/homework/max-of-vector/maxOfVector.hpp index f82fb2a1..3f311d12 100644 --- a/homework/max-of-vector/maxOfVector.hpp +++ b/homework/max-of-vector/maxOfVector.hpp @@ -3,6 +3,17 @@ #include int maxOfVector(const std::vector& vec) { - // TODO: Implement me :) - return {}; + if (vec.empty()) { + return {}; + } + + int max{vec.front()}; + + for (const int elem : vec) { + if (max < elem) { + max = elem; + } + } + + return max; }