Plus One
来源:互联网 发布:格鲁乌特种部队 知乎 编辑:程序博客网 时间:2024/05/01 09:40
Given a number represented as an array of digits, plus one to the number.
比较简单。
vector<int> plusOne(vector<int> &digits){ vector<int> answer; int c = 1; for (int i = digits.size() - 1; i >= 0; i--) { c += digits[i]; answer.insert(answer.begin(), c % 10); c = c / 10; } if (c > 0) { answer.insert(answer.begin(), c); } return answer;}
0 0
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Plus One
- Object C中文件后缀名
- Android动画 fillAfter和fillBefore
- 工厂方法模式(笔记)
- 数组逆序输出
- 微信红包算个毛 ——微信红包,仅仅是个游戏?!
- Plus One
- html5实现多文件的上传
- iOS App进入后台获取更多的运行时间
- 开灯问题
- LeetCode Word Break 解题报告
- 一位蜗牛程序员六年工作总结-2013
- asp.net mvc3的静态化实现1
- 蛇形填数
- PowerManagerService学习笔记一