leetcode之Remove Duplicates from Sorted List
来源:互联网 发布:linux中man的用法 编辑:程序博客网 时间:2024/06/07 03:18
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(head==NULL||head->next==NULL) {
return head;
}
ListNode* phead=head;
while(phead->next) {
if (phead->val==phead->next->val) {
ListNode* p =phead->next;
phead->next=p->next;
p->next=NULL;
delete p;
p=0;
} else {
phead=phead->next;
}
}
return head;
}
};
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(head==NULL||head->next==NULL) {
return head;
}
ListNode* phead=head;
while(phead->next) {
if (phead->val==phead->next->val) {
ListNode* p =phead->next;
phead->next=p->next;
p->next=NULL;
delete p;
p=0;
} else {
phead=phead->next;
}
}
return head;
}
};
- leetcode之Remove Duplicates from Sorted List
- LeetCode 之 Remove Duplicates from Sorted List
- LeetCode之Remove Duplicates from Sorted List
- LeetCode之Remove Duplicates from Sorted List
- LeetCode之Remove Duplicates from Sorted List
- LeetCode之Remove Duplicates from Sorted List
- 【LeetCode】之Remove Duplicates from Sorted List
- leetcode之Remove Duplicates from Sorted List
- leetcode之Remove Duplicates from Sorted List
- leetcode之Remove Duplicates from Sorted List
- 【Leetcode】之Remove Duplicates from Sorted List
- Leetcode 之 Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List :from LeetCode
- Leetcode - List - Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- leetcode之Remove Duplicates from Sorted List II
- leetcode之Remove Duplicates from Sorted List II
- mips64高精度时钟引起ktime_get时间不准,导致饿狗故障原因分析
- Codeforce 338 C. Divisor Tree(爆搜,3级)
- 九度1008最短路
- OM所经历的表
- 求两个或N个数的最大公约数和最小公倍数
- leetcode之Remove Duplicates from Sorted List
- 一个在清华附近蹲了17年的男人
- hdu 1709 The Balance 正负背包(01背包)
- 希尔排序
- 三、物理地址和段的概念
- UVA - 590 Always on the run
- [各种面试题】任务调度-拓排序
- 开发日志1
- Java Proguard 代码混淆