sheokand and string timecomplexity problem

solution link : CodeChef: Practical coding for everyone

please can someone tell me why i was getting 30 points however my code was similar to editorialist code @vijju please. Can you find the problem behind that

Try passing strings by reference instead of by value. It can be a good optimisation to start with.

done it but this is not sufficient i think because it gave me TLE to