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
|
1725 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/XgJKCkb1EjQ
def superReducedString(s): st=0 end=1 for i in range(len(s)): try: if(s[st]==s[end]): s=s[:st]+s[end+1:] st -= 1 end -= 1 st=max(st,0) end=max(end,1) print(s,st,end) else: st += 1 end += 1 except IndexError: return s if s else 'Empty String' return s
Best and performant approach in C++. Behold my simple C++ solution -
python recursive implementation
RUST: