Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Palindromic Numbers problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Palindromic Numbers problem solution we have given A and B, count the numbers N such that A ≤ N ≤ B, and N is a palindrome.
 
 
HackerEarth Palindromic Numbers problem solution

 

 

HackerEarth Palindromic Numbers problem solution.

def check(s):
q=s[::-1]
if s==q: return True
return False
t=input()
for i in range(t):
ans=0
x=raw_input()
a=int(x.split()[0])
b=int(x.split()[1])
for j in range(a,b+1):
if check(str(j)):
ans += 1
print ans
 
 

Second solution

#include <iostream>
using namespace std;

int ispallin(int n){
int arr[10],count = 0;
while(n!=0){
arr[count++] = n%10;
n/=10;
}
int i=0,j=count-1;
while(i<j){
if(arr[i]!=arr[j]) return 0;
i++; j--;
}
return 1;
}

int main()
{
int t;
cin >> t;
while(t--){
int a,b;
cin >> a >> b;
int ans = 0,count=0;;
for(int i=a;i<=b;i++) if(ispallin(i)) count++;
cout << count << endl;
}
return 0;
}
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes