← All questions
Coding
Find the next closest largest palindrome of a given number
Asked at
Uber
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Mirror the left half onto the right.
- 02Compare the mirrored result with the input.
- 03If needed, increment or decrement the middle half.
- 04Mirror again after carry or borrow.
- 05Handle all-nines and powers of ten separately.
Reference answer
Then expect these follow-ups
How do you compare candidate distances without integers?
Tests: follow-up reasoning
Why is simple mirroring insufficient sometimes?
Tests: complexity analysis
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question