2. Add Two Numbers
MediumLinked List
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each node contains a single digit. Add the two numbers and return the sum as a linked list in the same reverse-digit format. For example, l1 = [2,4,3] represents the number 342, and l2 = [5,6,4] represents the number 465. Their sum is 342 + 465 = 807, which is represented as [7,0,8]. You may assume the two numbers do not contain any leading zeros, except the number 0 itself.
Examples
Input: [2,4,3] [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807, represented as [7,0,8] in reverse-digit linked list format.
Constraints
- The number of nodes in each linked list is in the range [1, 100]
- 0 <= Node.val <= 9
- The list represents a number that does not have leading zeros
Loading...
Run checks all cases above. Submit evaluates all test cases.