Rivian FleetOS may represent long numeric identifiers as digit streams instead of converting them into fixed-width integers. Given two non-negative integers represented by linked lists, return their sum as a linked list.
Each list stores one decimal digit per node in reverse order, so the head contains the ones digit. Add the numbers digit by digit and propagate any carry to the next position.
Implement add_two_numbers(l1, l2). l1 and l2 are heads of singly linked lists containing digits from 0 through 9. Return the head of a new singly linked list containing the sum in reverse order. The input lists may have different lengths and must not be modified. For examples and JSON test cases, a list such as [2, 4, 3] represents the linked list 2 -> 4 -> 3, which encodes the number 342.
def add_two_numbers(l1, l2):