[Leetcode]66. Plus One
来源:互联网 发布:网络盗刷信用卡能查到 编辑:程序博客网 时间:2024/06/05 01:12
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
class Solution {public: vector<int> plusOne(vector<int>& digits) { add(digits, 1); return digits; }private: void add(vector<int>& digits, int digit) { int c = digit; for_each (digits.rbegin(), digits.rend(), [&c](int &d) { d += c; c = d / 10; d %= 10; }); if (c > 0) digits.insert(digits.begin(), 1); }};
0 0
- [LeetCode]66.Plus One
- LeetCode --- 66. Plus One
- [Leetcode] 66. Plus One
- [leetcode] 66.Plus One
- [leetcode] 66. Plus One
- Leetcode-66. Plus One
- 【leetcode】66. Plus One
- 66. Plus One LeetCode
- 【LeetCode】66. Plus One
- [LeetCode]66. Plus One
- 【LeetCode】66. Plus One
- LeetCode 66. Plus One
- LeetCode *** 66. Plus One
- leetcode 66. Plus One
- 【leetcode】66. Plus One
- leetcode 66. Plus One
- [LeetCode]66. Plus One
- Leetcode 66. Plus One
- 【音乐编程】基础知识一
- QQ安全问答
- centos升级python
- 编程之美2.17数组循环移位Java版
- 【转】console.log 用法
- [Leetcode]66. Plus One
- CCU(网络游戏用语)的解释
- Spark实战----(1)使用Scala开发本地测试的Spark WordCount程序
- CSS实现三栏式布局
- MyBatis处理表与表之间的关系
- 前端性能优化:创建对象二
- Intersection of Two Arrays II
- nginx之ngx_http_limit_req
- 专题四 Problem A