A big data scientist is developing a certain algorithm to make searching easier. To develop this algorithm, the scientist needs a list of all words whose first three characters match in the given input text. You are chosen to assist the scientist. Write a program that processes text and produces matching words. The output criteria and examples will help you in understand what is expected out of your program.
1
Expert's answer
2015-08-11T03:21:54-0400
Answer
#include <iostream> #include <fstream> #include <vector> using namespace std;
vector<string> find_words(vector<string> vs,string search) { vector<string>res; for (int k=0;k<vs.size();k++) { bool yes=1; for (int i=0;i<search.length();i++) if (search[i]!=vs[k][i]) yes=0; if (yes) res.push_back(vs[k]); } return res; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment