Reverse Integer Problem

Reverse Integer Problem — ExecCode Medium DSA Practice

Solve the Reverse Integer problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

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.

Examples

Input x = 123; Output 321. Input x = -120; Output -21

Constraints

-2^31 ≤ x ≤ 2^31 - 1

Practice Reverse Integer free on ExecCode. Browse DSA problems, topic map, and placement guides.