lintcode-加一-407
来源:互联网 发布:ubuntu wi fi上网 编辑:程序博客网 时间:2024/04/28 21:38
给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。
该数字按照大小进行排列,最大的数在列表的最前面。
样例
给定 [1,2,3]
表示 123, 返回 [1,2,4]
.
给定 [9,9,9]
表示 999, 返回 [1,0,0,0]
class Solution {public: vector<int> plusOne(vector<int>& digits) { if(digits.empty()) return digits; reverse(digits.begin(),digits.end()); int tmp=1,size=digits.size(); for(int i=0;i<size&&tmp!=0;++i){ tmp+=digits[i]; digits[i]=tmp%10; tmp/=10; } if(tmp!=0) digits.push_back(tmp); reverse(digits.begin(),digits.end()); return digits; }};
0 0
- lintcode-加一-407
- LintCode 407-加一
- [Lintcode] #407 加一
- LintCode 第407题 加一
- LintCode PlusOne 加一
- LintCode : 加一
- 加一(LintCode)
- LintCode 407. 加一
- lintcode----加一
- 加一,lintcode
- LintCode(加一)
- 【数组】[Lintcode]加一
- lintcode : 加一
- [LintCode]407.加一
- lintcode加一
- 加一 -LintCode
- 【Lintcode】加一
- lintcode 加一(Plus One )(Java)
- android 中 view 的宽度和高度
- 《剑指offer》包含min函数的栈
- Ubuntu下查看系统是多少位的
- 选择列表中的列无效,因为该列没有包含在聚合函数或 GROUP BY 子句中
- 页面加载时执行js代码的2种方式与差别
- lintcode-加一-407
- 单元测试
- umask
- ios 720全景资料
- varnish
- android开发第二弹--WebView总结
- 转 java Tomcat数据库连接池
- 一直以来对于返回jsp页面的认识错误
- PAT 1096. Consecutive Factors (20)