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
|
1689 Discussions
|
Please Login in order to post a comment
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
Here is my c++ solution, you can watch the explanation here : https://youtu.be/XgJKCkb1EjQ
In C using recursion, although it makes the time complexity O(nlogn):
My Solution Using Java
Time Complexity: 𝑂(𝑛)
Space Complexity: 𝑂(𝑛)
import java.util.*;
public static String superReducedString(String s) { Stack stack = new Stack<>();
}