You are viewing a single comment's thread. Return to all comments →
Python 3
def weightedUniformStrings(s, queries): alphabet = "_abcdefghijklmnopqrstuvwxyz" alphabet = {i:alphabet.index(i) for i in alphabet} weights = set() previous = "" length = 0 for letter in s: if previous == letter: length += 1 weights.add(alphabet[letter] * length) else: previous = letter length = 1 weights.add(alphabet[letter]) return list(map(lambda x: "Yes" if x in weights else "No", 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 →
Python 3