2025-09-22 17:10
Status: adult
Tags: leetcode leetcode-easy google strings arrays Removing Stars From a String Leetcode
Clear Digits
Code
class Solution(object):
def clearDigits(self, s):
"""
:type s: str
:rtype: str
"""
stack = []
for char in s:
if not char.isdigit():
stack.append(char)
else:
stack.pop()
return "".join(stack)
Explanation
- Just like
except it’s digits instead of stars.Removing Stars From a String
2024-12-20 17:34
Status: child leetcode leetcode-medium
Removing Stars From a String
Code
class Solution(object): def removeStars(self, s): """ :type s: str :rtype: str """ stack = [] for letter in s: if letter != "*": stack.append(letter) else: stack.pop(-1) return "".join(stack) # Time Complexity: O(n) # Space Complexitty: O(n)
Explanation
- way to simple don’t even need to explain
References
Link to original
References
Me