number. Find the non-negative integer closest to it, other than the number itself, that reads the same left to right and right to left (a palindrome). The distance between two numbers is the absolute value of their difference. If two numbers are equally close, pick the smaller one.
Return the answer as a string without leading zeros.number='4071' → '4114'
Two palindromes are nearby: 4004 (67 below) and 4114 (43 above). 4114 is closer.
number='99' → '101'
99 itself does not count. 88 and 101 are 11 and 2 away, so the answer is 101.
number='100' → '99'
Both 99 and 101 are exactly 1 away from 100. On a tie the smaller one wins: 99.
number.length ≤ 30number consists of digits and has no leading zeronumber='4071'
'4114'
Run checks the first 3 tests in your browser. Submit checks all 113 tests on the server, hidden ones included.