#K10756. Largest Palindromic Number
Largest Palindromic Number
Largest Palindromic Number
Given an integer \( n \), find the largest palindromic number strictly less than \( n \). A palindromic number is a number that remains the same when its digits are reversed. For example, given \( n = 123 \), the answer is 121. If no palindrome exists (for example, when \( n = 1 \)), output 0.
Note: A number \( x \) is a palindrome if \( x = \text{reverse}(x) \). The reverse of a number is obtained by reading its digits from right to left.
inputFormat
The input consists of a single integer \( n \) (\( 1 \leq n \leq 10^6 \)). The integer is read from standard input.
outputFormat
Output the largest palindromic number that is strictly less than \( n \) to standard output.
## sample123
121