Reverse Integer

Given a signed 32-bit integer num, return num with its digits reversed. If reversing num causes the value to go outside the signed 32-bit integer range [-2^31, 2^31 - 1], then return 0.

Running Tests

Example 1:

Input: num = 478

Output: 874

Example 2:

Input: num = -2001

Output: -1002

Example 3:

Input: num = 120

Output: 21