leetcode-Reverse Linked List
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* head) { if(!head||!head->next){return head;} struct ListNode *pre=head,*cur=head->next,*nxt; head->next=NULL; while(cur->next){ nxt=cur->next; cur->next=pre;pre=cur;cur=nxt; } cur->next=pre; return cur; }