@@ -0,0 +1,1292 @@
+package com.hackerearth;%0A%0Aimport java.util.Scanner;%0A%0A/**%0A * Given A and B, count the numbers N such that A %E2%89%A4 N %E2%89%A4 B and N is a palindrome.%0A */%0Apublic class PalindromicNumbers %7B%0A%0A    private static int%5B%5D palindrome = new int%5B100001%5D;%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        Scanner scanner = new Scanner(System.in);%0A        int T = scanner.nextInt();%0A        for (int i = 0; i %3C T; i++) %7B%0A%0A            int A = scanner.nextInt();%0A            int B = scanner.nextInt();%0A%0A            int count = 0;%0A            for (int j = A; j %3C= B; j++) %7B%0A                if (isPalindrome(j))%0A                    count++;%0A            %7D%0A            System.out.println(count);%0A        %7D%0A    %7D%0A%0A    private static boolean isPalindrome(int j) %7B%0A%0A        int reverseNumber = 0;%0A        int origNumber = j;%0A%0A        if (palindrome%5Bj%5D == 0) %7B%0A%0A            while (j != 0) %7B%0A                int lastDigit = j %25 10;%0A                j = j / 10;%0A                reverseNumber = reverseNumber * 10 + lastDigit;%0A            %7D%0A%0A            if (reverseNumber == origNumber) %7B%0A                palindrome%5BreverseNumber%5D = 1;%0A                palindrome%5BorigNumber%5D = 1;%0A            %7D else %7B%0A                palindrome%5BorigNumber%5D = -1;%0A            %7D%0A        %7D%0A%0A        return palindrome%5BorigNumber%5D == 1;%0A%0A%0A    %7D%0A%7D%0A

Given A and B, count the numbers N such that A ≤ N ≤ B and N is a palindrome.