This commit is contained in:
parent
fcaf05a364
commit
43527186ef
1 changed files with 13 additions and 0 deletions
13
easy/clear_digits.py
Normal file
13
easy/clear_digits.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# https://leetcode.com/problems/clear-digits
|
||||
|
||||
class Solution:
|
||||
def clearDigits(self, s: str) -> str:
|
||||
stack = []
|
||||
for i in range(len(s)):
|
||||
if '0' <= s[i] and s[i] <= '9':
|
||||
stack.pop()
|
||||
else:
|
||||
stack.append(s[i])
|
||||
return ''.join(stack)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue