/** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } */ /** * @param {ListNode} head * @return {ListNode} */ var reverseList = function(head) { //双指针 cur pre if(head === null){ returnnull } let cur,pre,temp cur = head pre = null temp = null while(cur){ temp = cur.next cur.next = pre pre = cur cur = temp } return pre };