Practice/Meta/Leetcode 445. Add Two Numbers II
CodingMust
You are given two linked lists representing two non-negative integers. The digits are stored in forward order, meaning the most significant digit is at the head of the list. Each node contains a single digit. Add the two numbers and return the sum as a linked list in the same forward order format.
You may assume the two numbers do not contain any leading zeros, except the number 0 itself.
[1, 100]0 <= Node.val <= 9Example 1:
Input: l1 = [7, 2, 4, 3], l2 = [5, 6, 4] Output: [7, 8, 0, 7] Explanation: 7243 + 564 = 7807
Example 2:
Input: l1 = [2, 4, 3], l2 = [5, 6, 4] Output: [8, 0, 7] Explanation: 243 + 564 = 807
Example 3:
Input: l1 = [0], l2 = [0] Output: [0] Explanation: 0 + 0 = 0
Example 4:
Input: l1 = [9, 9, 9], l2 = [1] Output: [1, 0, 0, 0] Explanation: 999 + 1 = 1000 (carry creates a new digit)