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.
===============================Answer===============================================
public class Solution {
public int[] plusOne(int[] digits) {
if(digits==null||digits.length==0) return null;
for(int i=digits.length-1;i>=0;i--) {
if(digits[i]==9) digits[i]=0;
else {digits[i]=digits[i]+1; return digits;}
}
int[] returnList = new int[digits.length+1];
returnList[0]=1;
for(int i=1;i<returnList.length;i++) {
returnList[i]=0;
}
return returnList;
}
}