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):weights=[]fori,charinenumerate(s):#compare unicode value of char to unicode of 'a' and add 1 to find weightweight=ord(char)-ord('a')+1ifi>0ands[i-1]==char:weight+=weights[-1]weights.append(weight)#get a set of the unique weightsweights=set(weights)return['Yes'ifqueryinweightselse'No'forqueryinqueries]
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