Hacker Earth Problems - Palindromic Numbers


Palindromes: 121, 11 , 11411
Not Palindromes: 122, 10
First line contains T, the number of testcases. Each testcase consists of two integers A and B in one line.
For each testcase, print the required answer in one line.
1 ≤ T ≤ 100 ≤ A ≤ B ≤ 105

Sample Input
2
10 13
20 30
Sample Output
1
1
Time Limit: 2 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Source Code:Language: Pythont=input()
while (t>0):
t-=1
a,b = map(int,raw_input().split())
count=0
for i in range(a,b+1):
if str(i) == str(i)[::-1]:
count+=1
if count == 0:
print count+1
else:
Problem Statement:Given A and B, count the numbers N such that A ≤ N ≤ B and N is a palindrome.
Examples:
Input:Output:Constraints:(Plaintext Link)(Plaintext Link)print count

Comments

Popular Posts