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 hereweights=set()fori,cinenumerate(s):u=ord(c)-ord('a')+1ifi>0andc==s[i-1]:w+=uelse:w=uifwnotinweights:weights.add(w)result=[]forqinqueries:ifqinweights:result.append("Yes")else:result.append("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 O(N) solution in Python: