LinkedList/add_two_numbers_linked_list library

➕ Add Two Numbers (Linked List Representation) — safe big-integer style add

Adds two non-negative integers represented by singly linked lists where digits are stored in reverse order (least significant digit first). The function returns a newly allocated linked list representing the sum in the same format.

Contract:

  • Inputs: l1, l2 (nullable heads of lists representing non-negative integers).
  • Output: head of new linked list representing the sum (nullable when both inputs are null).
  • Error modes: negative digits or non-integer values are not validated; caller must ensure valid input.

Complexity: Time O(max(m, n)), Space O(max(m, n)).

Example:

final l1 = LinkedListNode.fromList([2,4,3]); // 342
final l2 = LinkedListNode.fromList([5,6,4]); // 465
final sum = addTwoNumbersLinkedList(l1, l2);
// sum: [7,0,8] (807)