Write a Program to check whether a given number n is a Palindrome or not.
Definition of Palindrome:- A number which is equal to the reverse of the number.
Input Format
For each test case, you will get an positive integer input.
Constraints
10<=n<=10^4
Output Format
If number is a Palindrome then Print "YES"
If number is not a Palindrome number then Print "NO"
Sample Input 0
121
Sample Output 0
YES
Explanation 0
Number 121 is equal to its reverse so, the answer will be YES
ALSO READ: Print all unique prime factors
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int checkPalindrome(int num ){
int sum=0,rem;
while(num!=0){
rem=num%10;
sum=(sum*10)+rem;
num/=10;
}
return sum;
}
public static void main(String arg[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int t=n;
int s=checkPalindrome(n);
if(s==t)
System.out.println("YES");
else
System.out.println("NO");
}
}