From 7e4ad70499acd0e5e9cfadf6a39704f89a5b0179 Mon Sep 17 00:00:00 2001 From: Napalion Date: Sat, 1 Oct 2022 13:41:34 -0300 Subject: [PATCH] Q9_PalindromeNumber --- .../Q9_Palindrome_Number.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 leetCode Solutions/Q9_Palindrome_Number/Q9_Palindrome_Number.java diff --git a/leetCode Solutions/Q9_Palindrome_Number/Q9_Palindrome_Number.java b/leetCode Solutions/Q9_Palindrome_Number/Q9_Palindrome_Number.java new file mode 100644 index 0000000..1e48db8 --- /dev/null +++ b/leetCode Solutions/Q9_Palindrome_Number/Q9_Palindrome_Number.java @@ -0,0 +1,20 @@ +class Palindrome { + public boolean isPalindrome(int x) { + if(x < 0){ + return false; + } + int n = 0; + int copy = x; + int newnum = 0; + while(copy > 0){ + int y = copy%10; + newnum = (newnum*10) + y; + copy = copy/10; + + } + if(newnum != x){ + return false; + } + return true; + } +} \ No newline at end of file