Reverse an Integer

Problem Overview

  • Reverse the digits of a 32-bit signed integer while preserving its sign.
  • Input: int x; Output: the reversed integer; do not use strings; x in [-2^31, 2^31-1].
  • Applies to numeric data processing where digit reordering of integers is needed.
  • This Microsoft coding interview question is a classic interview problem used to assess core reasoning.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: