Remove Duplicates from Sorted List
来源:互联网 发布:殊知的意思是什么 编辑:程序博客网 时间:2024/06/08 05:06
/**
* 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) {
ListNode *tmp=head;
if (head==NULL)
return head;
else if(head->next==NULL)
return head;
else{
while(tmp->next!=NULL)
{
if(tmp->val==tmp->next->val)
{
tmp->next=tmp->next->next;
}
else
tmp=tmp->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) {
ListNode *tmp=head;
if (head==NULL)
return head;
else if(head->next==NULL)
return head;
else{
while(tmp->next!=NULL)
{
if(tmp->val==tmp->next->val)
{
tmp->next=tmp->next->next;
}
else
tmp=tmp->next;
}
return head;
}
}
};
0 0
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove duplicates from sorted list
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- mysql命令行连接查询
- JavaEE_Request和Response的区别
- 母函数(Generating function)详解 — TankyWoo
- leetcode -- Longest Common Prefix -- 简单O(n^2)就行
- nyoj 95 众数问题 【基础】
- Remove Duplicates from Sorted List
- HDU 3722 Card Game KM水题
- 决定以后坚持写自己的博客
- 并查集压缩路径
- SQL学习笔记(6)之DCL语句和事务
- Volley框架之一 如何使用
- 【Android游戏开发之六】在SurfaceView中添加系统控件,并且相互交互数据!
- UCI数据集与相关论文和源代码
- win7下使用python的几种方式