diff --git a/data_structures/linked_list.cpp b/data_structures/linked_list.cpp index 72003ba0c..e2323c489 100644 --- a/data_structures/linked_list.cpp +++ b/data_structures/linked_list.cpp @@ -167,6 +167,9 @@ void list::erase(int old_elem) { t->succ() = t->succ()->succ(); to_be_removed.reset(); if (t->succ() == nullptr) { + last = t; + } + if (first == last){ last = nullptr; } }