var swapPairs = function(head) {const dummy = new ListNode(null); // 设置虚拟头节点dummy.next = head; // 虚拟头节点连上节点let pre = dummy;while (head && head.next) {const temp = head.next;head.next = temp.next;temp.next = head;pre.next = temp;pre = head;head = head.next}return dummy.next};
