Skip to content
Decoder

Palindrome Number

Easy

Problem

Return true if the integer x reads the same forwards and backwards in decimal. Try to do it without converting the number to a string.

Example 1

Input
x = 121
Output
true

Example 2

Input
x = -121
Output
false
Why
reads 121- backwards

Example 3

Input
x = 10
Output
false
Why
reads 01 backwards

Constraints

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

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.