Add Lists Position by Position
Make a new list where the node at each position holds the sum of the values at that position in l1 and l2. If one list is shorter, treat its missing values as 0, so the result is as long as the longer list.
Linked lists appear in the tests as the list of their values, like [1,2,3]. Each node is a ListNode with .val and .next; the class is already defined for you.
Example 1
l1 [1,2,3]
l2 [10,20]
returns [11,22,3]
11, 22, then 3 + nothing.
Constraints
0 <= nodes in each list <= 50-100 <= Node.val <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.