class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *new_head = NULL; //指向新链表 头节点的指针
while(head){
ListNode *next = head -> next; //备份head->next
head ->next = new_head; //更新head->next
new_head = head;//移动new_head;
head = next;//遍历链表
}
return new_head;
}
};