Your question is Linked List Addition Program. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Josh Technology Group QA automation may need to validate arithmetic values represented as linked structures. Given two non-empty singly linked lists, add the numbers they represent and return the sum as a linked list.
Each node stores one decimal digit, and the digits are arranged in reverse order. The first node contains the ones digit. The input lists may have different lengths. Do not convert the lists into integers or strings, and do not modify the input lists.
Implement add_two_numbers(l1, l2). Each argument is the head of a singly linked list whose nodes contain a val digit and a next pointer. Return the head of a new linked list containing the sum in reverse digit order. The result must not contain unnecessary leading zero nodes, except that zero itself is represented by one node containing 0.
For the examples and test cases, lists are written as arrays for readability. The evaluator converts each array into a linked list before calling the function and converts the returned list back into an array.
def add_two_numbers(l1, l2):