Search topics...

Reverse Integer without using long long

medium
mathTime: O(log n)Space: O(1)Frequency: 4

Given a signed 32-bit integer, return its digits reversed, returning 0 if the result overflows.

Example 1:

Input: x = 123
Output: 321

Example 2:

Input: x = -123
Output: -321

Example 3:

Input: x = 1534236469
Output: 0
Explanation: Reversed value overflows 32-bit integer, so return 0.