Double a Number Represented as a Linked List
Medium
Topics
Given the head of a non-empty linked list whose nodes store the digits of a non-negative integer in order (most significant digit first, no leading zeros except the number 0 itself), return the list representing double that number.
Example 1
Input: head = [1,8,9] Output: [3,7,8] Explanation: 189 * 2 = 378.
Example 2
Input: head = [9,9,9] Output: [1,9,9,8]
Constraints
- 1 <= number of nodes <= 6
- 0 <= Node.val <= 9
- No leading zeros except the number 0.
Run ⌘' · Submit ⌘⏎