Question: Find the positions of all strings equal to a given string in a vector of strings. Instead of stopping at the first match, collect all

Find the positions of all strings equal to a given string in a vector of strings. Instead of stopping at the first match, collect all positions. This is in C++. It'd definitely help if you could explain how you solved it. Thanks in advance! Find the positions of all strings equal to a given string in a vector of strings. Instead of stopping at the first match, collect all positions. Complete the following file: vector_util.cpp 1 #include 2 #include 3 using namespace std; 45/** Finds the positions of all strings equal to a given string 7 in an array list of strings. @param words a vector of strings @param word the word to search for @return a vector of all matching positions 12 vector findAll(const vector & words, const string& word)13{14 vector int> pos; 1516}689101117 Submit Testers Running Tester.cpp fail fail pass words ->[how, much, wood, would, a, wood, chuck, chuck, if, a, wood, chuck, could, chuck, wood) findAll(words, "wood"): Expected: [2,'5,10,14] findAll(words,"a"): 61 Expected: [4,9] findAll(words, "the"): 0] Expected: [] Score 1/3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!