implemented Manacher's algorithm