public class Solution {
public int[] plusOne(int[] A) {
if(A.length >= 1)
{
int[] B = new int[A.length + 1];
int added = 1;
for(int i = A.length - 1 ; i >= 0 ; i--){
if(A[i] + added >= 10){
int tmp = (A[i] + added) %10;
added = (A[i] + added - tmp) / 10;
A[i] = tmp;
B[i + 1] = A[i];
}else{
A[i] = A[i] + added;
added = 0;
}
}
if(added > 0){
B[0] = added;
return B;
}
}
return A;
}
}
Plus One,觉得不能够开辟空间所以卡住了,原来还是可以的