mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Update add_two_numbers.py
This commit is contained in:
parent
60b5ec4a88
commit
4a03488022
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue