Created
December 29, 2025 08:40
-
-
Save rjchee/23ec59f67c6835f3c58a57dbf83837fa to your computer and use it in GitHub Desktop.
for cassidoo's #437 interview question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def replaceRepeats(s: str, n: int) -> str: | |
| return re.sub(f"{n}+", lambda m: str(len(m[0])), s) | |
| print(f"{replaceRepeats('1234500362000440', 0)=}") | |
| print(f"{replaceRepeats('000000000000', 0)=}") | |
| print(f"{replaceRepeats('123456789', 1)=}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment