count
of size 10 to store the frequency of each digit (0-9) in the input string num
.num
and increment the corresponding index in the count
array.leftPart
and rightPart
to build the left and right halves of the palindrome.leftPart
and rightPart
while decrementing its count by 2.rightPart
and concatenate leftPart
, the middle digit (if any), and rightPart
to form the final palindrome.