Sectionย 4. Chapterย 2
single
Challenge: Count Elements in an Iterator Range
Swipe to show menu
Task
Swipe to start coding
Implement count_in_range to return the number of elements in a std::vector<int> iterator range.
- Signature:
int count_in_range(std::vector<int>::iterator first, std::vector<int>::iterator last). - The range is [first, last).
- Use
std::distance. - Do not use loops, indexing, or
.size(). - Return the element count.
Solution
Everything was clear?
Thanks for your feedback!
Sectionย 4. Chapterย 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat