Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Find Element Index | Algorithms
C++ STL Containers and Algorithms

bookChallenge: Find Element Index

Taak

Swipe to start coding

Write a function named findIndex that takes a std::vector<int> and an int value as arguments. Use the std::find algorithm from the Standard Library to search for the value in the vector. If the value is found, return its index; if not, return -1.

  • Use the std::find algorithm to perform the search.
  • Return the zero-based index of the found element.
  • Return -1 if the value is not present in the vector.

Oplossing

solution.cpp

solution.cpp

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 2
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

What is Markdown and how is it used?

Can you show me some basic Markdown syntax?

What are the main features of Markdown?

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Find Element Index

Veeg om het menu te tonen

Taak

Swipe to start coding

Write a function named findIndex that takes a std::vector<int> and an int value as arguments. Use the std::find algorithm from the Standard Library to search for the value in the vector. If the value is found, return its index; if not, return -1.

  • Use the std::find algorithm to perform the search.
  • Return the zero-based index of the found element.
  • Return -1 if the value is not present in the vector.

Oplossing

solution.cpp

solution.cpp

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 2
single

single

some-alt