/9. Palindrome Number

9. Palindrome Number

Easy
Probability60.3% acceptance

Given a signed 32-bit integer input_value, return True if input_value is a palindrome (reads the same forwards and backwards), otherwise return False. Negative numbers are not palindromes. Do not convert the integer to a string in your implementation.

Example 1

Input: input_value = 1331

Output: True

Explanation: 1331 reads the same forwards and backwards.

Example 2

Input: input_value = -202

Output: False

Explanation: Negative numbers are not palindromes.

Example 3

Input: input_value = 12321

Output: True

Explanation: 12321 reads the same forwards and backwards.

Example 4

Input: input_value = 1001

Output: True

Explanation: 1001 reads the same forwards and backwards.

Example 5

Input: input_value = 120

Output: False

Explanation: 120 reads as 021 backwards, which is not the same.

Constraints

  • -231 <= input_value <= 231 - 1
  • Input is a signed 32-bit integer
  • Do not convert the integer to a string
Python (current runtime)

Case 1

Input: input_value = 444

Expected: True

Case 2

Input: input_value = 0

Expected: True

Case 3

Input: input_value = 1234

Expected: False

Case 4

Input: input_value = -101

Expected: False

Case 5

Input: input_value = 100

Expected: False