leetcode206题: https://leetcode-cn.com/problems/reverse-linked-list/submissions/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| var reverseList = function(head) { if (!head || !head.next) { return head }
let pre = null let cur = head let next while (cur) { next = cur.next cur.next = pre pre = cur cur = next } return pre };
|