We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 29c53b5 commit 772205fCopy full SHA for 772205f
java/009_Palindrome_Number.java
@@ -38,4 +38,26 @@ public boolean isPalindrome(int x) {
38
}
39
return true;
40
41
-}
+}
42
+
43
+// simpler code
44
45
+class Solution {
46
+ public boolean isPalindrome(int x) {
47
+ int r,s=0,number=x;
48
+ if(number<0){
49
+ return false;
50
+ }
51
+ while (number!=0){
52
+ r=number%10;
53
+ s= s*10 +r;
54
+ number/=10;
55
56
+ if (s==x){
57
+ return true;
58
59
+ else {
60
61
62
63
0 commit comments