← All problemsSign in

The Largest Palindrome

Given a number $X$, find the minimum value $t$ such that $X-t$ gives a palindrome. $Example:$ X = 5000, then the largest palindrome less than 5000 is 4994. Therefore, t = 6. The input consists of the value $X.$ Print the value of largest palindrome and $t$ in the output. ###Constraints - 1 <= X <= 10^15 ###Sample Input 1: 1000 ###Sample Output 1: 999 1 ###Sample

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start