/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
//双指针算法
struct ListNode* reverseList(struct ListNode* head)
{
struct ListNode* tmp;
struct ListNode* prve=NULL;
struct ListNode* cur=head;
while(cur)
{
tmp=cur->next;
cur->next=prve;
prve=cur;
cur=tmp;
}
return prve;
}
力扣206. 反转链表
猜你喜欢
转载自blog.csdn.net/congfen214/article/details/129540581
今日推荐
周排行