Find the Closest Palindrome
HardLeetCodeConstructive Algorithms
Approach hintTry it first, then revealHide
Only a few candidates can win: mirror the first half, mirror the first half plus or minus one, and the all-nines and 10...01 numbers of neighbouring lengths. Exclude the input itself and break ties toward the smaller value.