Workaround for TLE prob of O(n)sol


#1

Using append instead of + in the return string clears the problem.
e.g: ret.append(s.top()+"/"); instead of ret=ret+s.top()+"/";
This solves the problem. While + creates a new list concatenating the given strings and returning the new list , append works “in place” and doesn’t return anything .


#2

Thanks! This worked.


#3

Thank you so much this worked!


#4

Thanks man!
This saved me a lot of time.