Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

palindrome find in java

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();
        int temp = num;

        int rev = 0;
        while (num > 0) {
            rev = rev * 10 + num % 10;
            num /= 10;
        }
        System.out.println(temp==rev?"palindrome":"not palindrome");
    }
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #palindrome #find #java
ADD COMMENT
Topic
Name
7+4 =