【LeetCode 08】206 反转链表

阅读 86

2022-08-02


【LeetCode 08】206 反转链表

文章目录

  • ​​【LeetCode 08】206 反转链表​​
  • ​​一、题意​​
  • ​​二、思考过程​​

一、题意

【LeetCode 08】206 反转链表_反转链表

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/


struct ListNode* reverseList(struct ListNode* head){

} //返回3

二、思考过程

【LeetCode 08】206 反转链表_数据结构_02

【LeetCode 08】206 反转链表_反转链表_03

struct ListNode* reverseList(struct ListNode* head){
struct ListNode *tmp;
struct ListNode *pre=NULL;
while(head){
tmp=head->next;
head->next=pre;
pre=head;
head=tmp;
}
return pre;
}


精彩评论(0)

0 0 举报