ListNode示例

来源:互联网 发布:2d图像转3d算法 编辑:程序博客网 时间:2024/06/05 14:30



ListNode* partition(ListNode* head, int x) {    ListNode res(0), mid(0);    if (!head) return NULL;    ListNode* small=&res;    ListNode* big=&mid;        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;}


0 0
原创粉丝点击