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.
// Complete the weightedUniformStrings function below.functionweightedUniformStrings(s,queries){varcode;varprevChar;varprevCharCount;vardic=Object.create(null);for(vari=0;i<s.length;i++){code=s.charCodeAt(i)-96;if(prevChar===code){prevCharCount++;}else{prevCharCount=1;prevChar=code;}dic[code*prevCharCount]=true;}varresult=[];for(vari=0;i<queries.length;i++){result.push(dic[queries[i]]?"Yes":"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 →
javascript solution: