A relay station displays a numeric beacon ID on a rotating drum. When a technician flips the drum end-to-end, its digits are read out in reverse order; if that reversed reading would begin with one or more zero digits, those leading positions simply go dark and are omitted, exactly as an ordinary number never carries leading zeros. Starting from the beacon's original ID, the technician flips the drum once to get an intermediate reading, then flips the resulting drum a second time to get a final reading. Determine whether that final reading is identical to the original beacon ID.
A single line containing one non-negative integer num, the beacon's original ID, written normally (no leading zeros unless the value itself is 0).
Print true (lowercase, no quotes) if flipping the drum twice returns exactly the original ID, otherwise print false.
0 <= num <= 1000000000Example 1
Input
526
Expected
true
Explanation
Flipping 526 once reverses its digits to 625. Flipping 625 once more reverses its digits back to 526. The final reading, 526, matches the original beacon ID, so the answer is true.
Example 2
Input
1800
Expected
false
Explanation
Flipping 1800 once would reverse its digits to '0081', but the leading zero positions go dark, leaving 81. Flipping 81 once more reverses it to 18. The final reading, 18, does not match the original ID 1800, so the answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →