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

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate