标签:leetcode
</pre>简单题不解释, 维护一个进位即可<pre name="code" class="java">public class Solution { public int[] plusOne(int[] digits) { int c = 1; for(int i = digits.length - 1; i >=0; i --){ if(c == 0)break; digits[i] += c; if(digits[i] > 9){ c = 1; digits[i] -= 10; }else { c = 0; } } if (c > 0){ int [] d = new int[digits.length + 1]; d[0] = c; return d; }else return digits; } }
标签:leetcode
原文地址:http://blog.csdn.net/youmengjiuzhuiba/article/details/44902771