两数相加LeetCode第二题
答案参考了谈论中的答案。
def addTwoNumbers( l1, l2):
cur= dummy = ListNode(0)
curry = 0
while l1 or l2 or curry:
if l1:
curry += l1.val
l1=l1.next
if l2:
curry += l2.val
l2=l2.next
cur.next = ListNode(curry%10)
cur = cur.next
curry = curry //10
return dummy.next