Search topics...
All Problems

Reverse Integer without using long long

Solution Approach
Was this helpful?
MediummathExpected: O(log n) time, O(1) space

Problem

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.
Reference solution unlocks after your first submission
Loading...