You are viewing a single comment's thread. Return to all comments →
vector<string> weightedUniformStrings(string s, vector<int> queries) { vector<string> yn(queries.size(), "No"); vector<int> w; while(!s.empty()){ int j; int weight = 0; for(j = 0; j < s.length(); j++){ if(s[j] == s[0]){ weight += (s[0] - 96); w.push_back(weight); } else break; } s.erase(0, j); } for(int i = 0; i < queries.size(); i++){ for(int k = 0; k < w.size(); k++){ if(w[k] == queries[i]){ yn.at(i) = "Yes"; break; } } } return yn; }
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →