You are viewing a single comment's thread. Return to all comments →
Great solution. For more readability, you can use negative sequence indices in Python to specify an offset from the end of the stack, like so:
def super_reduced_string(s): res = [] for c in s: if res and res[-1] == c: res.pop() else: res.append(c) res = ''.join(res) return res or "Empty String"
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Great solution. For more readability, you can use negative sequence indices in Python to specify an offset from the end of the stack, like so: