We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Weighted Uniform Strings
Weighted Uniform Strings
Sort by
recency
|
785 Discussions
|
Please Login in order to post a comment
c++
}
c++ vector weightedUniformStrings(string s, vector queries) { set weight; int count = 1; for (int i = 0; i < s.size(); ++i) { int currentWeight = (s[i] - 'a' + 1); if (i > 0 && s[i] == s[i - 1]) { count++; } else { count = 1; } weight.insert(count * currentWeight); } vector result; for (int q : queries) { if (weight.find(q) != weight.end()) { result.push_back("Yes"); } else { result.push_back("No"); } } return result; }
Java:
Python