SanketAndStrings showing TLE

My code is working fine but showing TLE for one of the cases.Is there any other we should use so that i can avoid TLE.