做外贸可以在哪些网站注册,网站优化搜索,设计合理的网站网页归档,找别人做网站可以提供源码吗206. 反转链表 - 力扣#xff08;LeetCode#xff09; 思路#xff1a;创建三个指针n1,n2,n3#xff0c;遍历原链表#xff0c;通过三者之间的关系将链表反转。下面给出图示#xff1a;
下面给出题解代码#xff1a;
typedef struct ListNode ListNode;
struct List…
206. 反转链表 - 力扣LeetCode 思路创建三个指针n1,n2,n3遍历原链表通过三者之间的关系将链表反转。下面给出图示
下面给出题解代码
typedef struct ListNode ListNode;
struct ListNode* reverseList(struct ListNode* head)
{//如果原链表为空直接返回NULLif(head NULL){return NULL;}//原链表不为空ListNode*n1 NULL;ListNode*n2 head;ListNode*n3 head-next;while(n2){n2-next n1;n1 n2;n2 n3;if(n3!NULL){n3 n3-next;}}return n1;
}
完