Leetcode-7题:Reverse Integer

题目

Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321

代码:

********需注意整数溢出********

public int reverse(int x) {
    long sum = 0;
    while (x != 0) {
        sum = sum*10 + x%10;
        if (sum>Integer.MAX_VALUE || sum

你可能感兴趣的:(Leetcode-7题:Reverse Integer)