This commit is contained in:
parent
5ee734e9a5
commit
dcc322307d
1 changed files with 17 additions and 0 deletions
17
medium/process_string_with_special_operations_i.py
Normal file
17
medium/process_string_with_special_operations_i.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# https://leetcode.com/problems/process-string-with-special-operations-i
|
||||
|
||||
class Solution:
|
||||
def processStr(self, s: str) -> str:
|
||||
result = []
|
||||
for ch in s:
|
||||
match ch:
|
||||
case '#':
|
||||
result *= 2
|
||||
case '%':
|
||||
result.reverse()
|
||||
case '*':
|
||||
if len(result) > 0:
|
||||
result.pop()
|
||||
case _:
|
||||
result.append(ch)
|
||||
return ''.join(result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue