Leetcode#83 Remove Duplicates from Sorted List

原题地址

基本模拟,记得最后把尾节点next置为NULL...

代码:

 1 ListNode *deleteDuplicates(ListNode *head) {
 2         ListNode *h = NULL;
 3         ListNode *t = NULL;
 4         
 5         while (head) {
 6             if (!h)
 7                 h = t = head;
 8             else if (head->val != t->val) {
 9                 t->next = head;
10                 t = t->next;
11             }
12             head = head->next;
13         }
14         if (t)
15             t->next = NULL;
16         
17         return h;
18 }
原文地址:https://www.cnblogs.com/boring09/p/4267120.html