One minute
Leetcode 2119
The idea of this solution is that any number that has a 0 at the end will result in a different number after reversed twice.
This is shown using the numbers:
3210reversed equals123which reversed again equals32131000reversed equals13which reversed again equals31
The only exception for this rule in the number 0. because 0 zero reversed any amount of times equals 0.
func isSameAfterReversals(num int) bool {
return num == 0 || num % 10 != 0
}
Read other posts