From a95b34f8a74c39f540e102346d92dbf3a470f147 Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Sun, 30 Aug 2026 12:40:00 +0200 Subject: [PATCH] Max of vector done. --- homework/max-of-vector/maxOfVector.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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; }