LeetCode:Plus One
来源:互联网 发布:java正则表达式全匹配 编辑:程序博客网 时间:2024/05/21 11:32
Total Accepted: 73167 Total Submissions: 233149 Difficulty: Easy
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.
Subscribe to see which companies asked this question
Hide Similar Problems
code:
class Solution {public: vector<int> plusOne(vector<int>& digits) { int len = digits.size(); reverse(digits.begin(), digits.end()); int carry=1; for(int i=0;i<len && carry;i++) { int tmp =digits[i] + carry; carry = tmp / 10; tmp %= 10; digits[i]=tmp; } if(carry) digits.push_back(carry); reverse(digits.begin(),digits.end()); return digits; }};
0 0
- LeetCode: Plus One
- LeetCode Plus One
- [Leetcode] Plus One
- LeetCode: Plus One
- leetcode 33: Plus One
- [LeetCode] Plus One
- [leetCode] Plus One
- 【leetcode】Plus One
- [LeetCode]Plus One
- [leetcode]Plus One
- LeetCode-Plus One
- [leetcode] plus one
- LeetCode - Plus One
- [LeetCode] Plus one
- LeetCode:Plus One
- leetcode之Plus One
- leetcode plus one
- LeetCode | Plus One
- maven核心,pom.xml详解
- 试着开始自己写点东西
- 【SSH项目实战】国税协同平台-16.登录过滤器
- 学习日记:ajax的产生的背景、原理、特点与应用
- Leptonica在VS2010中的编译一,编译它依赖于库
- LeetCode:Plus One
- Multi-Task Learning with Low Rank Attribute Embedding for Person Re-identification
- JavaWeb 输出随机验证码图片
- javascript中判断radio是否选中的方法
- 数字图像处理四大函数库优缺点
- 第十周练习 1010 又一版 A+B
- 关于angular中指令调用controller的方法:&
- Vim设置颜色主题(colorscheme)
- UITextFiled时时获取当前输入的字符长度