LeetCode-Plus One
来源:互联网 发布:淘宝网男士真皮皮衣 编辑:程序博客网 时间:2024/06/03 11:13
作者:disappearedgod
文章出处:http://blog.csdn.net/disappearedgod/article/details/39255303
时间:2014-9-13
题目
Plus One
Total Accepted: 19009 Total Submissions: 60196My SubmissionsGiven 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.
想法
代码
public class Solution { public int[] plusOne(int[] digits) { int carry = 1; int[] arr = new int[digits.length + 1]; int i = digits.length-1; for(; i >= 0; i--){ digits[i] += carry; carry = digits[i] / 10; digits[i] %= 10; arr[i] = digits[i]; } if(carry == 0) return digits; else{ arr[0] = carry; return arr; } }}
结果
My Submissions for Plus One
返回
LeetCode Solution(持续更新,java>c++)
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
- 腾讯 2015年校招 笔试 附加题
- Connection Establishment in TCP 2
- HTTP协议很经典的解释
- TCP: Reliable Data transfer 3
- linux下memcached的启动/结束的方式
- LeetCode-Plus One
- TCP: terminating a connection 3
- Flow Control in TCP 3
- POJ-2404 Jogging Trails (中国邮递员)
- Linux下安装MySQL后设置root密码
- Struts1标签库
- Port Address Translation: saving IP addresses
- java中的线性表的内部实现(ArrayList、LinkedList)
- 如何对待一个人好