Merge branch 'main' of git.bumpsoo.dev:bumpsoo/leetpycode

This commit is contained in:
bumpsoo 2024-11-02 22:58:22 +09:00
commit d74f67ea6b
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# https://leetcode.com/problems/delete-characters-to-make-fancy-string
class Solution:
def makeFancyString(self, s: str) -> str:
l = 0
old = None
result = []
for ch in s:
if old == None or old != ch:
old = ch
l = 1
result.append(old)
elif old == ch and l <= 2:
result.append(old)
l += 1
return ''.join(result)