84. Add Two Numbers Stored as Lists
MediumLinked lists
Two non-negative integers are stored as linked lists of digits, with the least significant digit first (so 342 is written [2, 4, 3]). Return their sum as a list in the same format.
Neither number has leading zeros, except the number 0 itself.
A linked list is passed as ListNode objects with val and next. The tests write lists as arrays.
Example 1
Input: a = [2, 4, 3], b = [5, 6, 4] Output: [7, 0, 8] Explanation: 342 + 465 = 807
Constraints
1 ≤ nodes in each list ≤ 100Each value is a digit 0–9