Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 683 Bytes

9 Palindrome Number 6f9d651b72ef4558a564a7dd80c396d0.md

File metadata and controls

32 lines (23 loc) · 683 Bytes

9. Palindrome Number

Palindrome Number - LeetCode

class Solution {
    public boolean isPalindrome(int x) {
       StringBuilder test = new StringBuilder();

        StringBuilder s = new StringBuilder(String.valueOf(x));

        for (int i = s.length() -1 ; i >= 0 ; i--){
            test.append(s.substring(i , i+1));
        }

    
      return test.toString().equals(s.toString());
    }
}
class Solution {
    public boolean isPalindrome(int x) {
        StringBuilder s = new StringBuilder(String.valueOf(x));
        s.reverse();
       
        return s.toString().equals(x + "");
    }
}