标签:each amp this com color list dup node 引用
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
.
Subscribe to see which companies asked this question
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* deleteDuplicates(struct ListNode* head) { struct ListNode *pNode = head; while(NULL != pNode&&NULL != pNode->next){ if(pNode->val == pNode->next->val){ pNode->next = pNode->next->next; } else{ pNode = pNode->next; } } return head; }
LeetCode OJ 83. Remove Duplicates from Sorted List
标签:each amp this com color list dup node 引用
原文地址:http://www.cnblogs.com/YuNanlong/p/6029840.html