Leetcode 83. 删除排序链表中的重复元素

 83. Remove Duplicates from Sorted List

解题代码:

 1 class Solution {
 2 public:
 3     ListNode* deleteDuplicates(ListNode* head) 
 4     {
 5         ListNode* p = head;       
 6         while (p && p -> next ) 
 7         {
 8             if (p -> val == p -> next -> val) 
 9                 p -> next = p -> next -> next;
10             else 
11                 p = p -> next;
12         }
13         return head;
14     }
15 };

  

  

原文地址:https://www.cnblogs.com/sunbines/p/10620264.html