solution 2 using Manacher Algorithm