01.Palindrome Number

EasyMath

// Mission briefing

Given an integer x, determine whether it is a palindrome.

An integer is a palindrome if it reads the same forward and backward.

Return true if x is a palindrome; otherwise return false.

Example 1:

Input:
121

Output:
true

Example 2:

Input:
-121

Output:
false

Example 3:

Input:
10

Output:
false

// Constraints

  • -2^31 <= x <= 2^31 - 1

Time limit: 5s ·  Memory limit: 256 MB

Hint 1

Negative numbers can never be palindromes.

Hint 2

Try comparing the number with its reverse.

Hint 3

Can you solve it without converting the number to a string?

Solution.java