# LeetCode[Math] - #66 Plus One

1. 数字的较高位存在数组的头上，即num1表示数字1239

2. 每一位（数组中的每个元素）的取值范围为0~9

Java - 304 ms

```public int[] plusOne(int[] digits) {
if(digits == null){
return null;
}
// check if it is all 9
boolean allNine = true;
for(int digit : digits){
if(digit!=9){
allNine = false;
}
}

if(allNine){
int result[] = new int[digits.length+1];
result[0] = 1;
return result;
}else {
for(int i=digits.length-1;i>=0;i--){
if(digits[i]<9){
digits[i]++;
break;
}else{
digits[i]=0;

}
}
}
return digits;
}```

简单测试程序

LeetCode[Math] - #66 Plus One

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

Given a non-negative number represented as an array of digits, plus one to the number. The di

Question: Given a non-negative number represented as an array of digits, plus one to the numb
Given a non-negative number represented as an array of digits, plus one to the number. The di

Part 64 - C# Tutorial - How and where are indexers used in .net Part 65 - C# Tutorial - Index

One Shot One Kill 对于一个狙击手来说，One Shot One Kill 是每个狙击手的理想。 最近连续看了《双