链接

    1. /**
    2. * Definition for singly-linked list.
    3. * struct ListNode {
    4. * int val;
    5. * struct ListNode *next;
    6. * };
    7. */
    8. struct ListNode* deleteDuplicates(struct ListNode* head){
    9. if(head == NULL)
    10. {
    11. return head;
    12. }
    13. struct ListNode *pre = head;
    14. while(pre->next != NULL)
    15. {
    16. if(pre->val == pre->next->val)
    17. {
    18. pre->next = pre->next->next;
    19. }
    20. else
    21. {
    22. pre = pre->next;
    23. }
    24. }
    25. return head;
    26. }

    image.png