public class Solution {
public ListNode DeleteDuplicates(ListNode head) {
if(head == null || head.next == null){
return head;
}
var node = new ListNode(head.val);
var tmp = node;
head = head.next;
while(head != null){
if(head.val != node.val){
node.next = new ListNode(head.val);
node = node.next;
}
head = head.next;
}
node = tmp;
return node;
}
}版权声明:本文为博主原创文章,未经博主允许不得转载。
LeetCode -- Remove Duplicates from Sorted List
原文:http://blog.csdn.net/lan_liang/article/details/48576027