Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #a = [9,9,9]
- #b = [1,1]
- #[1, 0, 2, 0]
- def sol(a,b):
- a,b = a[::-1], b[::-1]
- if len(b)>len(a):
- a,b = b,a
- b.extend([0]*(len(a)-len(b)))
- res = [0]*len(a)
- for i in range(len(a)-1):
- temp=res[i]+a[i]+b[i]
- res[i]+=temp%10
- res[i+1]=temp//10
- temp = res[-1]+ a[-1]+b[-1]
- res[-1] = temp%10
- if temp>9:
- res.append(temp//10)
- return res[::-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement