For those who are getting TLE


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


Thanks, it helped!!!


Simple Sweet soln:


Can anyone tell me y this worked and y the 1st method gives TLE
ans =;
ans = ‘/’+ans;