leetcode Partition List
来源:互联网 发布:艾力欧与知世怀孕虐文 编辑:程序博客网 时间:2024/04/29 14:47
class Solution {public: ListNode* partition(ListNode* head, int x) { ListNode* smallHead = new ListNode(0);// 增加头结点,简化代码 ListNode* notSmallHead = new ListNode(0); ListNode* notSmallPtr = notSmallHead; ListNode* smallPtr = smallHead; for (ListNode* ptr = head; ptr;){ ListNode* tmp = ptr->next; if (ptr->val < x){ smallPtr->next = ptr; smallPtr = ptr; } else{ notSmallPtr->next = ptr; notSmallPtr = ptr; ptr->next = NULL; } ptr = tmp; } smallPtr->next = notSmallHead->next; return smallHead->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
- Apache Commons fileUpload实现文件上传
- 文章标题
- 【Leetcode】之Binary Tree Level Order Traversal
- C-style string一些笔记
- 简单版Java访问MySQL数据库
- leetcode Partition List
- 留念——网络课程设计
- 消耗内存
- php学习(二) 之 基本语法
- 给,还是不给
- Docker 常用命令
- 圣剑传说 玛娜传奇(Legend of Mana)(LOM)全武器取得方法
- 文章标题
- commons-fileupload-1.2.1实现文件上传