Skip to content

Commit

Permalink
Resolved Issue piyushsharma220699#12 Palindrome Number
Browse files Browse the repository at this point in the history
I have completed the Palindrome Number solution in java hope it passes all the criteria of being merged . please also mark the label of
hacktoberfest-accepted . Also thank you for your support
  • Loading branch information
sahilahmed24 committed Oct 1, 2021
1 parent e5086fc commit 60ff3aa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Java/palindrome_num.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*Link Of Question : https://leetcode.com/problems/palindrome-number/
#12. Palindrome Number
Given an integer x, return true if x is palindrome integer
*/
//Solution :

public class Solution {
public boolean isPalindrome(int x) {
int sum = 0,target = x;
while (x > 0) {
int temp = x % 10;
x /= 10;
sum = sum * 10 + temp;
}
return sum == target;
}
}

/*
Sample Input 1 : x=121
Sample output 1 : true

Sample input 2 : x= -121
Sample output 1 : false
/*



0 comments on commit 60ff3aa

Please sign in to comment.