We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Strings
- Super Reduced String
- Discussions
Super Reduced String
Super Reduced String
Sort by
recency
|
1692 Discussions
|
Please Login in order to post a comment
My solution in Java. This is good enough approach because it is short, simple, and we dont have to modify the string during the loop until the end of the process.
Java 8
s=input() l=[] for i in s: if not l: l.append(i) else: if(l[-1])==i: l.pop() else: l.append(i) if not l: print("empty string") else: print(''.join(l))
Python 3