/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var doubleIt = function(head) {
const vals = []
let curr = head
while (curr) {
vals.push(curr.val)
curr = curr.next
}
let newVals = BigInt(vals.join('')) * 2n
newVals = String(newVals).split('')
let dummy = new ListNode()
let dummyCurr = dummy
for (const val of newVals) {
dummyCurr.next = new ListNode(val)
dummyCurr = dummyCurr.next
}
return dummy.next
};
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)