逆序遍历数组
public class Solution {
public int[] PlusOne(int[] digits) {
for (int i = digits.Length - 1; i >= 0; i--) {
if (digits[i] != 9) {
digits[i]++;
return digits;
}
digits[i] = 0;
}
int[] temp = new int[digits.Length + 1];
temp[0] = 1;
return temp;
}
}