s
to get rev_s
.s
, #
, and rev_s
to form new_s
.f
with the same length as new_s
to store the failure function.new_s
to build the failure function f
.f
to determine the length of the longest palindromic prefix.s
to form the shortest palindrome.