You are viewing a single comment's thread. Return to all comments →
C++
string gridSearch(vector<string> G, vector<string> P) { for(int i = 0; i<G.size()-P.size()+1;i++){ int starting_index, coincidence = G[i].find(P[0]); while(coincidence != string::npos){ starting_index = coincidence; for(int j = 1 ; j<P.size() ; j++){ int post_index = G[i+j].find(P[j],starting_index); if(post_index != coincidence){ break; } if (j == P.size()-1) { return "YES"; } } coincidence = G[i].find(P[0], starting_index+1); } } return "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
The Grid Search
You are viewing a single comment's thread. Return to all comments →
C++