Add Two Numbers
MediumLinked List
Decode it first. Clues, constraints, pattern and plan before any code.Two non-negative whole numbers are stored as linked lists, one digit per node, in reverse order (the ones digit comes first). Add the numbers and return the sum as a linked list in the same reverse format.
2 -> 4 -> 3 + 5 -> 6 -> 4 → 7 -> 0 -> 8 (342 + 465 = 807)
0 + 0 → 0
9 -> 9 + 1 → 0 -> 0 -> 1 (99 + 1 = 100)The numbers can be far too long to fit in a regular integer, so add digit by digit.
Constraints
1 <= number of nodes in each list <= 1000 <= Node.val <= 9- Neither number has leading zeros, except the number 0 itself.