Baltic Olympiad in Informatics: 2013 Day 1, Problem 2
A string is a palindrome if it remains the same when it is read backwards. A number is palindrome-free if it does not contain a palindrome with a length greater than
Your task is to calculate the total number of palindrome-free numbers in a given range.
Input
The input contains two integers,
Output
The output should contain one integer: the total number of palindrome-free numbers in the range
Constraints
In test cases worth
Sample Input 1
Copy
123 321
Sample Output 1
Copy
153
Sample Input 2
Copy
123456789 987654321
Sample Output 2
Copy
167386971
Comments
How do I avoid a TLE? I'm currently checking numbers one by one to see if they are a palindrome
Looping through all the numbers from
to 
is far too slow. A faster approach uses an observation and this technique.