For those who are getting TLE


#1

at first i was storing strings as home, a, b etc then in final ans
ans = s.top()+ans;
ans = ‘/’+ans;
this was giving me TLE
so instead i did this
str = s.top();
reverse(str.begin(), str.end());
ans = ans+str;
ans= ans+’/’;
s.pop();
and in the end reverse the ans and return it


#2

Thanks, it helped!!!


#3

Simple Sweet soln:


#4

Can anyone tell me y this worked and y the 1st method gives TLE
ans = s.top()+ans;
ans = ‘/’+ans;
s.pop();