TheAlgorithms-C/leetcode/src/206.c

20 lines
376 B
C
Raw Normal View History

2019-09-03 23:52:24 +08:00
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* reverseList(struct ListNode* head){
struct ListNode *res = NULL;
while(head) {
struct ListNode *pre_node = head;
head = head -> next;
pre_node -> next = res;
res = pre_node;
}
return res;
}