17 lines
456 B
Python
17 lines
456 B
Python
# 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)
|
|
|