forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DHEERAJHARODE#559 from tamojeetK/main
Added Leetcode solution code for Palindrome
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class Palindrome { | ||
public static boolean isPalindrome(int n) { | ||
int temp = n; | ||
int rem; | ||
int ans = 0; | ||
while(n>0){ | ||
rem = n%10; | ||
ans = ans*10+rem; | ||
n=n/10; | ||
} | ||
if(ans==temp){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
public static void main(String[] args){ | ||
int N = 124321; | ||
boolean res = isPalindrome(N); | ||
System.out.print(res); | ||
} | ||
} |