Solution
This problem can be solved by using different approaches. Let's see them one by one.
Approach1(Manually Reverse the Number)
Algorithm:
 Take the number as an input.
 Store it in a temporary variable.
 Reverse the number.
 Compare the reversed number with the temporary number.
Code:
public class PalindromeNumber {
public static void main(String[] args) {
int Number = 121131;
int Temp = Number;
int Reverse = 0,Rem;
while(Number > 0) {
Rem = Number % 10;
Reverse = Reverse * 10 + Rem;
Number /= 10;
}
if(Temp == Reverse) {
System.out.printf("The Number %d is a Palindrome Number",Temp);
}
else{
System.out.printf("The Number %d is not a Palindrome Number", Temp);
}
}
}
Output:
Practice it on online java compiler for better understanding.
Program Flow Diagram:
Complexity Analysis
Let’s see how efficient this algorithm is by understanding its time and space complexity.

Time Complexity
Let the number be n.
As shown in the above program, we divide the number n by 10 in each iteration until the number n becomes 0.
So total number of steps required = log10(n).
Time complexity = O(log10(n))

Space Complexity
We are only using three variables for this case: one to store the number, one to store the remainder, and one to reverse the number.
So overall space complexity becomes O(1).
Approach2(Take the Number as String)
Algorithm:
The steps are as follows 
 Take the number as a string.
 Store it in a temporary variable.
 Reverse the string.
 Compare the reverse string with the temporary string.
Code:
public class PalindromeNumber {
public static void main(String[] args) {
String Number = "121131";
String Reverse = "";
int len = Number.length();
int i = len  1;
while(i >= 0) {
Reverse = Reverse + Number.charAt(i);
i;
}
if(Number.equals(Reverse)) {
System.out.printf("The Number " + Number + " is a Palindrome Number");
}
else{
System.out.printf("The Number " + Number + " is not a Palindrome Number");
}
}
}
Output:
Program Flow Diagram:
Complexity Analysis
Let’s see how efficient this algorithm is by understanding its time and space complexity.

Time Complexity
Here, in this case, we are taking the Number as a string, reversing the string by traversing it from right to left.
Time complexity = O(length of the string)
Now, the length of the string = log10(n)
So, Time complexity = O(log10(n))

Space Complexity
Here also, we are not allocating extra space. So, Space Complexity = O(1)
Approach3(Take the Number as a String and use the Two Pointers Method)
Algorithm:
The steps are as follows 
 Take the Number as a string.
 Use two pointers where one points to the beginning of the string and the other one point to the end of the string.
 Run a loop until the left pointer crosses the right pointer.
 Compare the characters pointed by the pointers.
 If they are the same, move the left pointer one step right and the right pointer one step left.
 If they are not the same, the number is not a palindrome and return from the loop.
Code:
public class PalindromeNumber {
public static void main(String[] args) {
String Number = "121131";
int left = 0;
int right = Number.length()  1;
while(left < right) {
if(Number.charAt(left) != Number.charAt(right)) {
System.out.println("The Number "+ Number +" is not a palindrome");
return;
}
left++;
right;
}
System.out.println("The Number "+ Number+" is a Palindrome");
}
}
Output:
Also check out Addition of Two Numbers in Java here.
Program Flow Diagram:
Complexity Analysis
Let’s see how efficient this algorithm is by understanding its time and space complexity.
 Time Complexity

Here also, We are traversing the length of the string, but here the number of steps at max would be (length of the string) / 2. So the time complexity here is O(length of string / 2).
Now, length of the string = log10(n)
So, Time complexity = O(log10(n))

Space Complexity
Here also we are not using any extra spaces. So, Space complexity = O(1)
Check out this problem  Check If A String Is Palindrome
Must Read What are Loops in Java.
You can also read about Palindrome Number in Python here.
FAQs

What is a palindrome number?
A palindrome number is a number that reads the same if we reverse the number.

What are the examples of palindrome numbers?
Some examples of the palindrome numbers are 121, 33233 etc.

How does the Palindrome Program work?
The palindrome program checks whether a number is a palindrome or not by reversing the number and checking for equality.

Which data structure can be used for Palindrome Program?
In the palindrome program, for a number of length n, we compare the ith digit with (n  i  1)th digit. If it is found the same, we move forward. So in that scenario, the Deque data structure would be suitable.
Key Takeaways
In this article, we have extensively discussed the Palindrome Program topic and its implementation in Java.
Here in this blog, we started with the basic introduction. We discussed the problem statement with an example. Then, we discussed different approaches to solve the problem and their implementations in Java with proper explanation using the program flow diagram.
We hope that this blog has helped you enhance your knowledge regarding the Palindrome Program and if you would like to learn more, check out our articles on Array Programs in Java Maximum of All Subarrays of Size K. Do upvote our blog to help other ninjas grow.
Recommended Readings:
Head over to our practice platform Coding Ninjas Studio to practice top problems, attempt mock tests, read interview experiences, and much more.!
Happy Reading!