标签:delete each let head sorted tno 列表 bsp code
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 public ListNode deleteDuplicates(ListNode head) { 2 ListNode curNode=head; 3 while (curNode != null && curNode.next != null) 4 { 5 if (curNode.val == curNode.next.val) 6 { 7 curNode.next = curNode.next.next; 8 }else 9 { 10 curNode = curNode.next; 11 } 12 } 13 return head; 14 }
83. Remove Duplicates from Sorted List
标签:delete each let head sorted tno 列表 bsp code
原文地址:http://www.cnblogs.com/wzj4858/p/7728646.html