比较简单 没啥好注意的
/**
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
class Solution {
public:
/**
*
* @param head ListNode类
* @return ListNode类
*/
ListNode* deleteDuplicates(ListNode* head) {
// write code here
ListNode* cur = head;
if(!head)
return nullptr;
while(cur->next){
if(cur->val == cur->next->val){
cur->next = cur->next->next;
}
else
cur =cur->next;
}
return head;
}
};

京公网安备 11010502036488号