题解 | #反转链表#
反转链表
https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
class Solution {
public:
ListNode* ReverseList(ListNode* head) {
if(!head ) return head;
ListNode *first = NULL, *curr = head, *c_next;
while(curr){
c_next = curr->next;
curr->next = first;
first = curr;
curr = c_next;
}
return first;
}
};
