You are viewing a single comment's thread. Return to all comments →
Simple C++ solution:
vector<string> ans; char lastc = s[0]; int lastw = s[0] - 96; int sz = s.size(); set<int>w; w.insert(lastw); for (int i=1;i<sz;++i) { if (s[i] == lastc) lastw+=s[i]-96; else lastw = s[i] - 96; lastc = s[i]; w.insert(lastw); } for (auto q:queries) { if (w.find(q) == w.end()) ans.push_back("No"); else ans.push_back("Yes"); } return ans;
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
Simple C++ solution: