#66 plus one
老笨今天终于完成了租房,明天开始搬砖之旅 加油啊
range()函数用法
转自 http://blog.csdn.net/chiclewu/article/details/50592368
range(stop)
range(start, stop[, step])
range函数是一个用来创建算数级数序列的通用函数,返回一个[start, start + step, start + 2 * step, ...]结构的整数序列;range函数具有一些特性:
1.如果step参数缺省,默认1;如果start参数缺省,默认0。
2.如果step是正整数,则最后一个元素(start + i * step)小于stop。
3.如果step是负整数,则最后一个元素(start + i * step)大于stop。
4.step参数必须是非零整数,否则抛出VauleError异常。
所以在for循环中可以生成从大到小的数
题目:
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.
You may assume the integer do not contain any leading zero, except the number 0 itself.
The digits are stored such that the most significant digit is at the head of the list.
开始没看懂..原谅我一只菜鸟飞过
题解:数组的最后一个数加1操作,返回新的数组。如果有进位,要往前进位。比如 [5,9] --> [6,0] [9,9] -->[1,0,0]