leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

delete-characters-to-make-fancy-stringV1.py (496B)


      1 class Solution:
      2     def makeFancyString(self, s: str) -> str:
      3 
      4         prior = ""
      5         prior_count = 1
      6         ret_str = ""
      7 
      8         for index, char in enumerate(s):
      9 
     10             if char == prior:
     11                 if prior_count >= 2:
     12                     continue
     13                 else:
     14                     prior_count += 1
     15                     ret_str += char
     16             else:
     17                 prior = char
     18                 prior_count = 1
     19                 ret_str += char
     20 
     21         return ret_str