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 };

 

  

  

相关文章:

  • 2021-09-21
  • 2021-05-31
  • 2021-10-28
  • 2022-01-01
  • 2021-05-01
  • 2021-09-30
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-08-20
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案