Class Solution
- java.lang.Object
-
- g2101_2200.s2119_a_number_after_a_double_reversal.Solution
-
public class Solution extends Object
2119 - A Number After a Double Reversal.Easy
Reversing an integer means to reverse all its digits.
- For example, reversing
2021
gives1202
. Reversing12300
gives321
as the leading zeros are not retained.
Given an integer
num
, reversenum
to getreversed1
, then reversereversed1
to getreversed2
. Returntrue
ifreversed2
equalsnum
. Otherwise returnfalse
.Example 1:
Input: num = 526
Output: true
Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
Example 2:
Input: num = 1800
Output: false
Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
Example 3:
Input: num = 0
Output: true
Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
Constraints:
0 <= num <= 106
- For example, reversing
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isSameAfterReversals(int num)
-