题目描述:整数反转
代码实现:Github
Java代码
public class question_07 {/*** 不断地弹出x最后的数,然后推入res的尾部* 时间复杂度 O(log|x|) 空间复杂度 O(1)* @param x* @return*/public int Solution(int x) {int res = 0;while (x != 0) {if (res < Integer.MIN_VALUE/10 || res > Integer.MAX_VALUE/10) {return 0;}int dight = x % 10;x /= 10;res = res * 10 + dight;}return res;}}
