Add two numbers by converting them to lists


  • 0
    K

    """
    list1 = []
    list2 = []
    while l1:
    list1.append(l1.val)
    l1 = l1.next
    while l2:
    list2.append(l2.val)
    l2 = l2.next
    n1 = "".join(map(str, list1))
    n2 = "".join(map(str, list2))
    n = int(n1)+int(n2)
    list_n = [int(d) for d in str(n)]
    return list_n
    """


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.