leetcode:Partition List
来源:互联网 发布:三国志9需要优化哪些 编辑:程序博客网 时间:2024/06/05 12:05
/** * 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) { if(head==NULL)return NULL;ListNode *low = new ListNode(-1), *low_tail = low;ListNode *high = new ListNode(-1), *high_tail = high;ListNode *cur = head;while(cur){ if(cur->val<x) { low_tail->next = cur; cur = cur->next; low_tail = low_tail->next; low_tail->next = NULL; } else { high_tail->next = cur; cur = cur->next; high_tail = high_tail->next; high_tail->next = NULL; }} low_tail->next = high->next; return low->next; }};
0 0
- LeetCode: Partition List
- LeetCode Partition List
- LeetCode: Partition List
- [Leetcode] Partition List **
- [Leetcode] Partition List
- [LeetCode] Partition List
- leetcode 81: Partition List
- [Leetcode] Partition List
- leetcode 118: Partition List
- [LeetCode]Partition List
- [leetcode]Partition List
- LeetCode-Partition List
- [leetcode] Partition List
- LeetCode - Partition List
- [LeetCode] Partition List
- LeetCode 86: Partition List
- LeetCode:Partition List
- 【leetcode】Partition List
- android中 欢迎界面的实现
- Python函数参数的传递
- Android中Application类用法
- POJ2299 Ultra-QuickSort
- 微信JS-SDK官方支付接口在THINKPHP中使用
- leetcode:Partition List
- Linear models for regresion(回归)
- 同一时间内相同程序只运行一个进程运行
- UDP可靠传输,VTCP和UDX协议比较
- 判断点是否在视景体内的参考资料
- 观察者模式
- apache中虚拟目录总是403 Forbidden的问题
- 虚拟浏览器(WebClient)应用简单例子
- LibSVM-3.20在Matlab2014a中的使用(VS2013)