Weighted Uniform Strings

  • + 0 comments
    def weightedUniformStrings(s, queries):
        out = []
        variants = set()
        prev = None
        for value in s:
            code_point = ord(value) - 96
            if value != prev:
                temp = code_point
            else:
                temp += code_point
            prev = value
            variants.add(temp)
        [out.append('Yes' if x in variants else 'No') for x in queries]
        return out