Medium

Quiz

#7 Reverse Integer

APPROACH

Reverse the decimal digits of signed 32-bit integer x. Return 0 if the reversed value falls outside the range [-231, 231 - 1]. Storing 64-bit integers is not permitted.

Example 1:

Input: x = 123
Output: 321

Example 2:

Input: x = -123
Output: -321

Example 3:

Input: x = 120
Output: 21
1 of 4
1:00

What is the optimal approach for this problem?