Weighted Uniform Strings

  • + 0 comments

    Python

    def weightedUniformStrings(s, queries):
        st = set()
        uniform = [max(re.findall(f'{i}+', s)) for i in set(s)]
        [st.add((ord(j[0]) - 96) * n) for j in uniform for n in range(1, len(j)+1)]
        return  ['Yes' if q in st else 'No' for q in queries]