Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Reverse Integer

Medium

Topics
Math

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

Example 1

Input:  x = 123
Output: 321

Example 2

Input:  x = -123
Output: -321

Example 3

Input:  x = 120
Output: 21

Constraints

  • -2^31 <= x <= 2^31 - 1
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access