0
点赞
收藏
分享

微信扫一扫

【LeetCode 08】206 反转链表


【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 条评论