<commit_before>import LinkedList

# Problem description:      
# Solution time complexity: 
# Comments:                 

# Linked List Node inside the LinkedList module is declared as:
#
#   class Node:
#       def __init__(self, val, nxt=None):
#           self.val = val
#           self.nxt = nxt
#

def AddTwo(left: LinkedList.Node, right: LinkedList.Node) -> LinkedList.Node:
    raise NotImplementedError()<commit_msg>Update solution.py<commit_after>import LinkedList

# Problem description:      Perform addition of two values, represented as two linked lists of their digits
# Solution time complexity: O(n)
# Comments:                 

# Linked List Node inside the LinkedList module is declared as:
#
#   class Node:
#       def __init__(self, val, nxt=None):
#           self.val = val
#           self.nxt = nxt
#

def AddTwo(left: LinkedList.Node, right: LinkedList.Node) -> LinkedList.Node:
    def ListReverse(head: LinkedList.Node) -> LinkedList.Node:
        prev = None
        curr = head
        
        while curr != None:
            nxt      = curr.nxt
            curr.nxt = prev
            prev     = curr
            curr     = nxt

        return prev

    dummy     = LinkedList.Node(0)
    dest      = dummy

    left      = ListReverse(left)
    right     = ListReverse(right)

    leftNode  = left
    rightNode = right

    carry     = 0

    while leftNode != None or rightNode != None:
        leftVal  = leftNode.val  if leftNode  else 0
        rightVal = rightNode.val if rightNode else 0

        total    = carry + leftVal + rightVal
        carry    = total // 10
        addVal   = total % 10

        dest.nxt = LinkedList.Node(addVal)
        dest     = dest.nxt

        if leftNode:  leftNode  = leftNode.nxt
        if rightNode: rightNode = rightNode.nxt

    if carry > 0:
        dest.nxt = LinkedList.Node(carry)
        dest     = dest.nxt

    return ListReverse(dummy.nxt)
{'fraction_non_alphanumeric': 0.08242612752721618, 'fraction_numerical': 0.004665629860031105, 'mean_word_length': 1.9242424242424243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3400045', 'n_tokens_mistral': 589, 'n_tokens_neox': 567, 'n_words': 168}