You are viewing a single comment's thread. Return to all comments →
Python3
def weightedUniformStrings(s, queries): values = set() values.add(ord(s[0]) - 96) first_value = amount = ord(s[0]) - 96 for i in range(1, len(s)): if s[i] == s[i-1]: amount += first_value values.add(amount) else: first_value = amount = ord(s[i]) - 96 values.add(first_value) return ['Yes' if q in values else 'No' for q in queries]
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 →
Python3