Explanation

481.Check if a Number Is a Palindrome

Easy
Given a non-negative integer n, return whether it reads the same forwards and backwards. The full-reversalFull ReversalBuilding the completely reversed number (same technique as the Reverse a Number problem) and comparing it to the original. approach is the most direct way to think about it: reverse everything, then compare. The half-reversalHalf ReversalStopping the reversal loop halfway through, once n is no longer bigger than the reversed-so-far half, then comparing the two halves directly. approach does only as much work as is actually needed to answer the question — there's no point reversing the second half of the digits when they can just be compared against the first half directly as the loop goes.

Example 1:

Input: n = 121

Output: true

Example 2:

Input: n = 123

Output: false

Example 3:

Input: n = 10

Output: false

+ 5 hidden test cases run on Submit.

Constraints:

  • ●0 ≤ n ≤ 1000000000

n =

121