Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range, return 0.
Constraints: -231 ≤ x ≤ 231 - 1 (i.e. -2,14,74,83,648 to 2,14,74,83,647)
Given an integer like 123, you need to produce 321. You cannot convert to a string — the problem explicitly forbids it. No BigInt, no 64-bit types. The digits are trapped inside the number. How do you extract them one by one, using only arithmetic?
Drag the scrubber below and watch the trace table. Pay attention to how each digit comes out and how the result builds up. The mechanism will reveal itself.
Try dragging to bigger numbers. What happens near 1.5 billion?