diff --git a/homework/max-of-vector/maxOfVector.hpp b/homework/max-of-vector/maxOfVector.hpp index f82fb2a1..2d5ebe38 100644 --- a/homework/max-of-vector/maxOfVector.hpp +++ b/homework/max-of-vector/maxOfVector.hpp @@ -1,8 +1,18 @@ #pragma once -#include +#include // better will be exception #include int maxOfVector(const std::vector& vec) { - // TODO: Implement me :) - return {}; + if (vec.empty()) { + return std::numeric_limits::min(); + } + + int max = vec[0]; + for (auto const el : vec) { + if (max < el) { + max = el; + } + } + + return max; }