Your question is Add Two Numbers as Linked Lists. 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.
Airtel Digital receives numeric values in digit-wise form for some lightweight processing workflows. Given two non-negative integers represented by singly linked lists, return their sum as a singly linked list.
Each node stores one decimal digit, and the digits are arranged in reverse order: the head contains the least significant digit. The two numbers may have different lengths. Do not convert the linked lists into integers or strings.
Implement add_two_numbers(l1, l2), where l1 and l2 are heads of singly linked lists. Each node has an integer val from 0 to 9 and a next pointer. Return the head of a new linked list containing the sum, also in reverse digit order. The input lists must not be modified.
For test cases, list notation such as [2, 4, 3] represents the linked list 2 -> 4 -> 3.
def add_two_numbers(l1, l2):