Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Count Elements in an Iterator Range | Iterators with Algorithms
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C++ STL Iterators
Sectionย 4. Chapterย 2
single

single

bookChallenge: 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

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 4. Chapterย 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt