比较验单,理清逻辑注意细节
123456789101112
var reverseList = function(head) { let prev = null let cur = head while(cur){ // 这一步我忘记了,没有把next的值保存下来,直接给cur.next赋值了 const next = cur.next cur.next = prev prev = cur cur = next } return prev};