left
and right
to integers and calculate the square roots, rounding up for left
and down for right
to define the search range for palindrome roots.k
within the range [1, MAGIC)
where MAGIC
is the square root of the maximum possible palindrome root.k
, generate two potential palindrome roots: one by concatenating k
with the reverse of k
(even-length palindrome), and another by concatenating k
with the reverse of k
without the last digit (odd-length palindrome).