# Remove Duplicates from Sorted List

## 题目描述

Given a sorted linked list, delete all duplicates such that each element appear only once.

Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.

## 链接地址

http://www.lintcode.com/en/problem/remove-duplicates-from-sorted-list/

## 解法

     ListNode *deleteDuplicates(ListNode *head) {
}
while (dummyNode != NULL) {
if (dummyNode->next != NULL && dummyNode->val == dummyNode->next->val) {
ListNode *temp = dummyNode->next;
dummyNode->next = dummyNode ->next->next;
delete temp;
} else {
dummyNode = dummyNode->next;
}
}
}
• 本文已收录于以下专栏：

## LeetCode :: Remove Duplicates from Sorted List[详细分析]

Given a sorted linked list, delete all duplicates such that each element appear only once. For ex...

## LeetCode82:Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct num...

## Remove Duplicates from Sorted List I,II

Remove Duplicates from Sorted List   Given a sorted linked list, delete all duplicates such that ea...

## [83] Remove Duplicates from Sorted List

• camlot_
• 2016年06月28日 09:48
• 151

## 和大神们学习每天一题(leetcode)-Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once. For ex...

举报原因： 您举报文章：Remove Duplicates from Sorted List 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)