lc2816. Double a Number Represented as a Linked List

Runtime: 156ms, faster than 100.00% of JavaScript online submissions.

In other words, I beat JavaScript developers around the world.😤 Are you serious?

My simple solution with stack.

/**
 * 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) {
  let st = [];
  let h = head;
  while (h) {
    st.push(h);
    h = h.next;
  }
  h = st.pop();
  let c = 0;
  while (h) {
    let v = h.val * 2 + c;
    c = v >= 10 ? 1 : 0;
    v = v % 10;
    h.val = v;
    h = st.pop();
  }
  h = head;
  if (c) {
    h = new ListNode(1, h);
  }
  return h;
};