Reverse a Number Problem

Reverse a Number Problem — ExecCode School DSA Practice

Solve the Reverse a Number problem on ExecCode. Free online school DSA practice in Numbers & Math Logic. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a single whole number. Your task is to reverse the order of its digits. For example, if you get 123, you should make it 321. If the number is negative, like minus 123, it should still be negative after reversing its digits, becoming minus 321. Print the new reversed number.

Examples

Input 123; Output 321. Input -123; Output -321

Constraints

-2^31 <= N <= 2^31-1

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