LeetCode(86) Partition List
来源:互联网 发布:淘宝的吕官方旗舰店 编辑:程序博客网 时间:2024/05/07 20:36
代码如下:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* partition(ListNode* head, int x) { ListNode *newHead = new ListNode(0); newHead->next = head; ListNode *p1; p1 = newHead; while(p1->next != NULL) p1 = p1->next; ListNode *plusHead = new ListNode(0); p1->next = plusHead; ListNode *p3, *p4, *p5; p3 = newHead; p4 = newHead->next; p5 = plusHead; while(p4 != plusHead) { if(p4->val >= x) { p3->next = p4->next; p5->next = p4; p4->next = NULL; p4 = p3->next; p5 = p5->next; }else { p4 = p4->next; p3 = p3->next; } } p1 = newHead; while(p1->next != plusHead) p1 = p1->next; p1->next = plusHead->next; return newHead->next; }};
0 0
- LeetCode 86: Partition List
- LeetCode 86 Partition List
- [leetcode 86] Partition List
- leetcode-86 Partition List
- [LeetCode 86]Partition List
- leetcode || 86、Partition List
- LeetCode---(86) Partition List
- LeetCode 86 Partition List
- Leetcode[86]-Partition List
- leetcode[86]:Partition List
- Leetcode #86 Partition List
- LeetCode(86) Partition List
- leetcode 86: Partition List
- [Leetcode]#86 Partition List
- leetCode #86 Partition List
- leetcode 86:Partition List
- 【leetcode】【86】Partition List
- leetcode-Partition List-86
- wifi万能钥匙下载 v3.2.36 官方手机版
- MySQL基本语句
- select函数分析
- 数组下标为偶数,ASCII为偶数的字符重新输出,其他删除
- jni 使用java 调用C代码
- LeetCode(86) Partition List
- HDU 2571 命运(DP)
- p2098 求sky数
- Top k问题的一个应用
- uva12299 RMQ with Shifts(线段树基础)
- jni常见错误
- HDU 2795 Billboard(线段树啊 )
- 十六进制文本用eclipse转换可执行文件方法
- STM32F107(互联网型)外部晶振用25MHZ 而STM32F103却用8MHZ的原因及其时钟来源分析