###### Plus One

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.

public class Solution {
public int[] plusOne(int[] digits) {
if(digits==null||digits.length==0) return null;
int carry = 1;
int sum = 0;
int len = digits.length;
for(int i=len-1;i>=0;i--){
sum = digits[i]+carry;
digits[i] = sum%10;
carry = sum/10;
}
if(carry>0){
int[] a = new int[len+1];
a[0] = carry;
for(int i=0;i<len;i++){
a[i+1] = digits[i];
}
return a;
}
return digits;

}
}

#### LeetCode --- 66. Plus One

2015-03-19 21:53:21

#### Plus One python 题解

2015-04-23 20:15:08

#### LeetCode 66 — Plus One（C++ Java Python）

2014-04-02 08:53:48

#### LeetCode（66）Plus One

2015-08-18 15:38:10

#### 【LeetCode with Python】 Plus One

2014-07-06 15:21:09

#### LeetCode Plus One Java版解题报告

2015-01-10 23:03:51

#### [leetcode]Plus One C语言

2015-08-27 15:23:14

#### Plus One -- LeetCode

2014-03-28 07:04:57

#### 【leetcode】66. Plus One【java】

2016-12-17 15:43:36

#### [leetcode] 369. Plus One Linked List 解题报告

2016-06-28 23:52:19

Plus One