一、实现链表反转
function Node(data){
this.data = data
this.next = null
}
a = new Node(1)
b = new Node(2)
c = new Node(3)
a.next = b
b.next = c
function reverseNodeList(head){
let newHead = null
if(head == null||head.next == null){
return head
}
while(head!=null){
let next = head.next
head.next = newHead
newHead = head
head = next
}
return newHead
}
result = reverseNodeList(a)
while(result!=null){
console.log(result.data)
result = result.next
}