leetcode解题之66 # Plus One Java版
来源:互联网 发布:php debug pack怎么用 编辑:程序博客网 时间:2024/05/23 00:08
66. Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.
You may assume the integer do not contain any leading zero, except the number 0 itself.
The digits are stored such that the most significant digit is at the head of the list.
public int[] plusOne(int[] digits) { int length=digits.length; if(length==0||digits==null) return digits; //carry表示进位 int carry=1; for(int i=length-1;i>=0;i--) { int val=digits[i]+carry; carry=val/10; digits[i]=val%10; if(carry==0) return digits; } int res[]=null; if(carry>=1){ //int 数组默认值为0 res=new int[length+1]; //最高位置1 就可以,其他位,全是0 res[0]=carry; } return res; }
0 0
- leetcode解题之66 # Plus One Java版
- LeetCode Plus One Java版解题报告
- [leetcode-66]plus one(java)
- LeetCode 66 : Plus One (Java)
- [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 (Java)
- [LeetCode][Java] Plus One
- windows下WPS导致打开程序为未响应状态
- 2016老男孩Linux高薪运维28期
- 17.3.13 多任务学习 Multi-task learning
- Map
- 读书笔记-程序是如何跑起来的(第一章)
- leetcode解题之66 # Plus One Java版
- 通俗易懂的Map/Reduce原理
- xml学习小结1
- maven中GroupID 和ArtifactID怎么写
- 备考刷题:PAT中文版1001
- JTAG出错Bad JTAG communication问题的解决
- [Android Studio] Android Studio常用快捷键
- Java并发编程之基础知识和多线程简介
- ZigBee Router 概念