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.
题目的意思就是把这个数组代表的大数字加一,然后考虑进位的问题,如果都是9就要考虑加一位的问题。这是一个处理大数据的办法,当数字超出了整型的长度,我们就可以用这种办法。我们需要处理的就是进位问题。
public int[] plusOne(int[] digits) {
int flag = 1, sum;
for (int i = digits.length - 1; i >= 0;