Skip to content

Commit

Permalink
9. Palindrome Number
Browse files Browse the repository at this point in the history
  • Loading branch information
SE-MahmoudAbdelaal committed May 20, 2024
1 parent ef6ff59 commit 8095d47
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions leetcode/easy/PalindromeNumber.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class Solution {
public boolean isPalindrome(int x) {

String s=Integer.toString(x);
int div=1;
int numberofpow=s.length()-2;
int firstDigit=(int)Math.pow(div, numberofpow);
int lastDigit=x%10;

int numberofpow=s.length()-1;

int firstDigit=x/(int)Math.pow(10, numberofpow);
int lastDigit=Math.abs(x%10);


if (firstDigit==lastDigit) {
return true;

Expand Down

0 comments on commit 8095d47

Please sign in to comment.