Leetcode Problem 2119. A Number After a Double Reversal

2119. A Number After a Double Reversal

Leetcode Solutions

Check for Non-Zero Last Digit

  1. Check if the number is zero. If it is, return true because reversing zero will always result in zero.
  2. Check if the last digit of the number is zero (i.e., num % 10 == 0). If it is, return false because the number will lose the trailing zero after the first reversal, and it will not be the same after the second reversal.
  3. If neither of the above conditions is met, return true because any other number will remain the same after two reversals.
UML Thumbnail

Double Reversal Simulation

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...