leetcode

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 45edb85c1501f4dcd49c729218729b542f1f263f
parent dc148fa590a1c382eb5f4e4587f36d03fe009af0
Author: Andrew Laack <andrew@laack.co>
Date:   Sun, 20 Jul 2025 21:30:58 -0500

Completed delete characters to make fancy string

Diffstat:
Adelete-characters-to-make-fancy-string/delete-characters-to-make-fancy-stringV1.py | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/delete-characters-to-make-fancy-string/delete-characters-to-make-fancy-stringV1.py b/delete-characters-to-make-fancy-string/delete-characters-to-make-fancy-stringV1.py @@ -0,0 +1,21 @@ +class Solution: + def makeFancyString(self, s: str) -> str: + + prior = "" + prior_count = 1 + ret_str = "" + + for index, char in enumerate(s): + + if char == prior: + if prior_count >= 2: + continue + else: + prior_count += 1 + ret_str += char + else: + prior = char + prior_count = 1 + ret_str += char + + return ret_str