Update add_two_numbers.py

This commit is contained in:
marina 2023-08-07 15:51:56 -07:00 committed by GitHub
parent 60b5ec4a88
commit 4a03488022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ class Node:
self.val = val
self.next = None
def add_two_numbers(l1, l2):
n1, n2, i = '', '', 1
@ -25,11 +26,11 @@ def add_two_numbers(l1, l2):
n2 = int(n2[::-1])
n = str(n1 + n2)[::-1]
current = ListNode(n[0])
current = Node(n[0])
head = current
while i < len(n):
current.next = ListNode(n[i])
current.next = Node(n[i])
current = current.next
i += 1