B6ac3f82e760bf75c150751531881ff0
Problem 7: Reverse Integer

Problem 7: Reverse Integer

链接:https://leetcode.com/problems/reverse-integer/

难度等级: Easy(简单)

题干

Given a 32-bit signed integer, reverse digits of an integer.

题意

题意很简单,给定一个32bit大小的整数,翻转这个整数。

比如给定123,返回321.

样例

Example 1:

Input: 123
Output: 321
Example 2:

Input: -123
Output: -321
Example 3:

Input: 120
Output: 21

注意

Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

翻译:

翻转之后得到的结果需要在int的范围内,否则return 0

分析

top Created with Sketch.