大家好,又见面了,我是你们的朋友全栈君。
ListNode* partition(ListNode* head, int x) {
ListNode res(0), mid(0);
if (!head) return NULL;
ListNode* small=&res;
ListNode* big=∣
while (head) {
if (head->val < x) {
small->next = head;
small = small->next;
}
else {
big->next = head;
big = big->next;
}
head = head->next;
}
big->next = NULL;
small->next = mid.next;
return res.next;
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/126740.html原文链接:https://javaforall.cn