LeetCode 07. 整数反转
生活随笔
收集整理的這篇文章主要介紹了
LeetCode 07. 整数反转
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原題描述
個人解法思路
class Solution { public:int reverse(int x) {int temp=0;//需要返回的最后結果while(x!=0){if(temp>INT_MAX/10 || temp<INT_MIN/10)return 0;temp=temp*10+x%10; //個位變十位 同理x=x/10; //進行降位} return temp;} };?
總結
以上是生活随笔為你收集整理的LeetCode 07. 整数反转的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 年轻人倡导“数字排毒”,美国功能手机市场
- 下一篇: Leetcode 146. LRU 缓存