Challenge: Find Element Index
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::findalgorithm to perform the search. - Return the zero-based index of the found element.
- Return
-1if the value is not present in the vector.
Solución
solution.cpp
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
What is Markdown and how is it used?
Can you show me some basic Markdown syntax?
What are the main features of Markdown?
Awesome!
Completion rate improved to 6.67
Challenge: Find Element Index
Desliza para mostrar el menú
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::findalgorithm to perform the search. - Return the zero-based index of the found element.
- Return
-1if the value is not present in the vector.
Solución
solution.cpp
¡Gracias por tus comentarios!
single