标签:
给定一个已排序的链表,移除链表中的重复元素。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