dsa · easy

Reverse Integer

GreyOrangeMathFoundation

Given a signed 32-bit integer x, return x with its digits reversed. If reversing causes overflow outside [-2^31, 2^31-1], return 0.

Arguments

**Example:** x = 123321. x = -123-321.

Constraints

-2^31 <= x <= 2^31 - 1

Examples

Example 1

Input:
123

Expected:
321

Example 2

Input:
-123

Expected:
-321

Open in the Dojo editor