Reverse Integer

来源:互联网 发布:tk域名注册不了 编辑:程序博客网 时间:2024/06/11 04:10

题目:Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321

Test cases had been added to test the overflow behavior.

本题很简单,唯一值得注意的点是反转之后要做溢出检查,有两种方式,一可以每次得到结果都判断,二可以将32位先转成64位,再最后判断是否溢出。

一:


二:


0 0