时间复杂度 ,空间复杂度
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head == nullptr) return head;
ListNode *last = head, *now = head -> next;
while(now != nullptr) {
if(now -> val == last -> val) {
last -> next = now -> next;
now = last -> next;
}
else {
last = now;
now = now -> next;
}
}
return head;
}
};