Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
12-liner: substitute groupby solution in Clear category for Long Pressed by przemyslaw.daniel
import re
def long_pressed(text: str, typed: str) -> bool:
text = re.findall(r"(.)(\1*)", text)
typed = re.findall(r"(.)(\1*)", typed)
for (char1, group1), (char2, group2) in zip(text, typed):
if char1 != char2 or len(group2) < len(group1):
return False
return len(text) == len(typed) and text != typed
Sept. 18, 2022