首页 > 代码库 > Remove Duplicates from Sorted List

Remove Duplicates from Sorted List

题目 :

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

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

我的解法:

(1)算法思想:

顺序遍历一次即可,遇到重复的就删除。

(2)代码如下:

<script src="https://code.csdn.net/snippets/582290.js" type="text/javascript"></script>

Remove Duplicates from Sorted List