Remove Duplicates from Sorted List
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
auto fix = head;
if(fix == nullptr) return nullptr;
for (auto cursor = head->next; cursor != nullptr; cursor = cursor->next) {
if (fix->val != cursor->val) {
fix->next = cursor;
fix = cursor;
}
}
fix->next = nullptr;
return head;
}
};