Please HELP me to correct code

https://www.codechef.com/viewsolution/19356822

Search forum. This question is already answered many times. Also explain your approach when you ask question. And add question link.

I performed an addition of ASCII code of each character of the two substrings of string and then compared the sum of ASCII values of both substrings.

Problem link:

Sum of ASCII can be deceiving. ‘ad’ and ‘bc’ will have same sum afaik.

Thank you for helping.I was really frustrated