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...
分类:
其他好文 时间:
2015-04-18 17:23:35
阅读次数:
97
用单个保存的数字表示一个十进制数,实现+1操作。保存的第一个数一定要是有意义的(非零)。【思路】很容易想到把保存的数字转换为实际十进制数,然后+1,再按原格式保存,但很明显有超范围数据如何表示的问题。比如9876543210.(试过用long long类型也放不下?)所以要考虑几种情况:1.个位数字...
分类:
其他好文 时间:
2015-04-16 11:55:00
阅读次数:
107
题目链接https://leetcode.com/problems/plus-one/这是digit这类题里最简单的一道了,这类题基本都不难,但是需要把几个boundary case考虑到,这道题里需要考虑的是进位之后首位的情况。其他case以后遇到再提。class Solution {public...
分类:
其他好文 时间:
2015-04-16 06:42:24
阅读次数:
131
总结数据处理帖子http://blog.csdn.net/linhuanmars/article/details/39046243这道题看似简单,但是有个优化必须要考虑到,就是如果没有进位,则应该立即返回public class Solution { public int[] plusOne(...
分类:
其他好文 时间:
2015-04-15 08:24:19
阅读次数:
132
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...
分类:
其他好文 时间:
2015-04-13 08:15:12
阅读次数:
116
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...
分类:
其他好文 时间:
2015-04-11 22:26:13
阅读次数:
187
简单题不解释, 维护一个进位即可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]...
分类:
其他好文 时间:
2015-04-06 17:20:23
阅读次数:
155
一: Plus One
题目:
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.
...
分类:
其他好文 时间:
2015-04-05 21:59:23
阅读次数:
159
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.
class Solution {
p...
分类:
其他好文 时间:
2015-04-05 17:33:17
阅读次数:
89