Add Two Numbers II
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, with the most significant digit first (the way you write numbers). Add them and return the sum as a linked list in the same order.
7 -> 2 -> 4 -> 3 + 5 -> 6 -> 4 → 7 -> 8 -> 0 -> 7 (7243 + 564 = 7807)
2 -> 4 -> 3 + 5 -> 6 -> 4 → 8 -> 0 -> 7 (243 + 564 = 807)
0 + 0 → 0The numbers can be far too long to fit in a regular integer. Try not to reverse the input lists.
Constraints
1 <= number of nodes in each list <= 1000 <= Node.val <= 9- Neither number has leading zeros, except the number 0 itself.