JuniorMath

A Number After a Double Reversal

Reversing an integer means to reverse all its digits.

  • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.

Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.

Example 1
Inputnum = 526
Outputtrue
Reverse num to get 625, then reverse 625 to get 526, which equals num.
Example 2
Inputnum = 1800
Outputfalse
Reverse num to get 81, then reverse 81 to get 18, which does not equal num.

Constraints

  • 0 <= num <= 10^6

Asked at 4 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate