Reverse Integer Problem
Reverse Integer Problem — ExecCode Easy DSA Practice
Solve the Reverse Integer problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a signed 32-bit integer x, return x with its digits reversed. Your task is to if reversing x causes the value to go outside the signed 32-bit integer range [-2^31, 2^31 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
Examples
Input {"n": 123}; Output 321. Input {"n": -123}; Output -321. Input {"n": 120}; Output 21
Constraints
-2^31 <= x <= 2^31 - 1
Practice Reverse Integer free on ExecCode. Browse DSA problems, topic map, and placement guides.