From a5022c53f243204bfb30ddc82e92b684ae3bb00d Mon Sep 17 00:00:00 2001 From: Bolaji Boluwatife Date: Sun, 9 May 2021 20:24:05 -0700 Subject: [PATCH] fix: Corrected erase method in `data_structures/linked_list.cpp` (#1494) --- data_structures/linked_list.cpp | 3 +++ 1 file changed, 3 insertions(+) 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; } }