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.
defweightedUniformStrings(s,queries):# Write your code heredp=[]foriinrange(len(s)):weight=ord(s[i])-96ifi==0or(s[i]!=s[i-1]):dp.append(weight)else:dp.append(weight+dp[i-1])ans=[]dp=set(dp)forxinqueries:ifxindp:ans.append("Yes")else:ans.append("No")returnans
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 →
python solution