class Solution(object): def addTwoNumbers(self, l1, l2): k1=‘‘.join(list(map(str, l1))) k2=‘‘.join(list(map(str, l2))) nsum=int(k1)+int(k2) res=list(str(nsum)) return list(map(int,res)) l1=[1,2,3] l2=[1,1,1] x=Solution() print(x.addTwoNumbers(l1,l2))
输出
[2, 3, 4]
原文地址:https://www.cnblogs.com/sea-stream/p/10463764.html
时间: 2024-10-10 20:21:13