From 660c030d3de48415a84ac76cfa5bd3f4910edd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Paw=C5=82owski?= Date: Wed, 31 Jan 2024 21:55:53 +0100 Subject: [PATCH] Add solution with algorithm max_element for maxOfVector function --- homework/max-of-vector/maxOfVector.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homework/max-of-vector/maxOfVector.hpp b/homework/max-of-vector/maxOfVector.hpp index f82fb2a1..6afe5c59 100644 --- a/homework/max-of-vector/maxOfVector.hpp +++ b/homework/max-of-vector/maxOfVector.hpp @@ -1,8 +1,11 @@ #pragma once -#include +#include //sugestia? :D #include +#include //method with max_element algorithm + int maxOfVector(const std::vector& vec) { - // TODO: Implement me :) - return {}; + + std::vector::const_iterator resultIt = std::max_element(vec.begin(), vec.end()); + return *resultIt; }