← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one.
The closest is defined as the absolute difference minimized between two integers.
Interviewer-asked variant (per the Roblox interview report): the candidate was asked to solve it without converting the input to a string or array — i.e., handle the integer in-place. The reference solution below uses string mirroring for clarity; the no-string variant performs the same digit-mirroring with arithmetic on the integer.