leetcode -. 989 array of integer addition

This is the second questions completed today, this is better understood, within half an hour just fine ,,,

 1 class Solution:
 2     def addToArrayForm(self, A, K: int):
 3         s=''
 4         for i in range(len(A)):
 5             s+=str(A[i])
 6         add=int(s)+K
 7         b=[]
 8         add=str(add)
 9         for i in range(len(add)):
10             b.append(int(add[i]))
11         return b

Is the conversion between integers and strings and arrays.

 

I saw good people answer, use the divmod () function, the function I know too little, this is where the need to focus on learning, the future will again improved, fuel oil! ! !

                                                                                                      ——2019.9.18

Guess you like

Origin www.cnblogs.com/taoyuxin/p/11542568.html