shlogg · Early preview
Md Ariful Haque @mah-shamim

Doubling Linked List Numbers In O(1) Space

Double a number represented as a linked list by multiplying each digit by 2 and carrying over when necessary. Example: [1,8,9] becomes [3,7,8].

2816. Double a Number Represented as a Linked List
Medium
You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes.
Return the head of the linked list after doubling it.
Example 1:


Input: head = [1,8,9]
Output: [3,7,8]
Explanation: The figure above corresponds to the given linked list which represents the number 189. Hence, the returned linked list represents the number 189 * 2 = 378.

Example 2:


Input: head = [9,9,9]
Output: [1,9,9,8]
Explanation: The figure above corresponds to the given linked list which represents the number 999. Henc...