You are viewing a single comment's thread. Return to all comments →
Pythonic:
def weightedUniformStrings(s, queries): mem = accumulate(range(1, len(s)), lambda c, i: c+1 if s[i] == s[i-1] else 1, initial=1) mem = set(m[1] *(ord(m[0]) - 96) for m in zip(s, mem)) return ['Yes' if q in mem 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 →
Pythonic: