- 1.题目(LeetCode | 7 | easy):
|
|
- Example:
|
|
- 解:12345678910111213141516class Solution {public int reverse(int x) {long ret = 0; // x会越界,用longwhile(x != 0){ret = ret * 10 + x % 10; // 最高位开始算x = x/10;}if(ret > Integer.MAX_VALUE || ret < Integer.MIN_VALUE){ret = 0;}return (int)ret;}}
总结
暂无