leetcode989】的更多相关文章

For a non-negative integer X, the array-form of X is an array of its digits in left to right order.  For example, if X = 1231, then the array form is [1,2,3,1]. Given the array-form A of a non-negative integer X, return the array-form of the integer …
class Solution: def addToArrayForm(self, A, K): i = len(A) - 1 while i >= 0 and K > 0: A[i] += K K = A[i] // 10 if A[i] >= 10: A[i] %= 10 if i == 0: A = [0] + A i += 1 i -= 1 return A 上面这个是参考别人的解决方案,思路不好理解,我又从新写了一个啰嗦的: class Solution: def addToAr…