Skip to content

Commit a5022c5

Browse files
authored
fix: Corrected erase method in data_structures/linked_list.cpp (TheAlgorithms#1494)
1 parent fd029ae commit a5022c5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

data_structures/linked_list.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ void list::erase(int old_elem) {
167167
t->succ() = t->succ()->succ();
168168
to_be_removed.reset();
169169
if (t->succ() == nullptr) {
170+
last = t;
171+
}
172+
if (first == last){
170173
last = nullptr;
171174
}
172175
}

0 commit comments

Comments
 (0)