Palindrome Index | HackerRank

can anyone help me how to optimise this solution.
I’m getting tle.
i have used brute force solution.

there is discussion tab in which u can find the logic or approach to the problem.

https://www.hackerrank.com/challenges/palindrome-index/forum