题解 | #重排链表#
重排链表
https://www.nowcoder.com/practice/3d281dc0b3704347846a110bf561ef6b
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
void reorderList(ListNode *head) {
if(head==nullptr||!head->next||!head->next->next)return;
ListNode* h=head;ListNode* p=head;
while(h->next->next)h=h->next;
ListNode* t=h->next;
h->next=nullptr;
t->next=p->next;p->next=t;
reorderList(t->next);
}
};


SHEIN希音公司福利 222人发布