86. Partition List
来源:互联网 发布:it售后工程师岗位职责 编辑:程序博客网 时间:2024/06/02 09:20
这题1刷只想到用新的点,2刷试试不用新的点,直接在原链表中运行。
Ps 链表的申请 复习
/** * 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 *p = new ListNode(0); ListNode *q = new ListNode(0); ListNode *ph = p; ListNode *qh = q; while(head != NULL){ if(head -> val < x){ p -> next = head; p = p -> next; } else{ q -> next = head; q = q -> next; } head = head -> next; } p -> next = qh -> next; q -> next = NULL; return ph -> next; }};
0 0
- [LeetCode]86.Partition List
- LeetCode 86. Partition List
- [Leetcode] 86. Partition List
- LeetCode --- 86. Partition List
- 86. Partition List
- [leetcode] 86.Partition List
- [leetcode] 86. Partition List
- 86. Partition List
- [LeetCode]86. Partition List
- 86. Partition List
- 86. Partition List LeetCode
- 86. Partition List
- 86. Partition List
- 86. Partition List
- Leetcode 86. Partition List
- LeetCode *** 86. Partition List
- LeetCode 86. Partition List
- [LeetCode]86. Partition List
- [linux]当在unix系统中输入任何命令时导致command not found情况
- MySQL存错过程动态执行sql的方式来返回结果集
- 一个简易而有趣的爬虫——对草榴帖子的爬取
- PAT B1031. 查验身份证(15)
- android四大组件之ContentProvider
- 86. Partition List
- 87. Scramble String
- 88. Merge Sorted Array
- 89. Gray Code
- 90. Subsets II
- popupwindow中按钮的点击事件
- 92. Reverse Linked List II
- Android 抽屉效果
- Linux中__init、__devinit等初始化宏