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.
I think you could improve your algorithm by not making it O(n^2), here is mine, maybe it helps.
python#!/bin/pythonimportsysdefsuper_reduced_string(s):# Complete this functioni=0whilelen(s)>0:ifi==len(s)-1:returnselse:ifs[i]==s[i+1]:s=s[:i]+s[i+2:]i=0else:i+=1return"Empty String"s=raw_input().strip()result=super_reduced_string(s)print(result)
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
I think you could improve your algorithm by not making it O(n^2), here is mine, maybe it helps.