From dcd70a70916ab93327a0becdb1545dc7228c3830 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 22 Nov 2023 14:13:49 +0100 Subject: [PATCH] fix longest span --- ex01/src/Span.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex01/src/Span.cpp b/ex01/src/Span.cpp index 4a547c8..620cfdd 100644 --- a/ex01/src/Span.cpp +++ b/ex01/src/Span.cpp @@ -41,7 +41,7 @@ int Span::shortestSpan() const int Span::longestSpan() const { - if (this->_vector.size() == 0) + if (this->_vector.size() < 2) throw std::exception(); return *std::max_element(this->_vector.begin(), this->_vector.end()) - *std::min_element(this->_vector.begin(), this->_vector.end()); }