You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can use a generator to easily iterate over the linked lists, and zip_longest to match corresponding values. If one linked list is longer than the other, zip_longest will use the fillvalue (0 in this case, which won't affect the sum).
"""
from itertools import zip_longest
class Solution:
def solve(self, l0, l1):
head=pre=LLNode(0)
carry = 0
for x,y in zip_longest(it(l0), it(l1), fillvalue=0):