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.
vector<string>weightedUniformStrings(strings,vector<int>queries){// build the setmap<int,int>mp;intlast=0;for(inti=0;i<s.size();i++){if(i!=0&&s[i]==s[i-1]){last+=s[i]-'a'+1;mp[last]=1;}else{last=s[i]-'a'+1;mp[last]=1;}}vector<string>result;for(inti=0;i<queries.size();i++){if(mp[queries[i]])result.push_back("Yes");elseresult.push_back("No");}returnresult;}
Cookie support is required to access HackerRank
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, video here : https://youtu.be/xhpzPQBB9ts