From 211e2ab83794b44feba12441b7d8e2602794081f Mon Sep 17 00:00:00 2001 From: SAMBHAV MISHRA <136839720+Sambhav234@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:44:36 +0530 Subject: [PATCH] Update singlyLinkedList.cpp updating the tail in deletepos function --- Lecture044 Linked List Day1/singlyLinkedList.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lecture044 Linked List Day1/singlyLinkedList.cpp b/Lecture044 Linked List Day1/singlyLinkedList.cpp index 1683d159..ef64f2b3 100644 --- a/Lecture044 Linked List Day1/singlyLinkedList.cpp +++ b/Lecture044 Linked List Day1/singlyLinkedList.cpp @@ -111,6 +111,10 @@ void deleteNode(int position, Node* & head) { cnt++; } + if(curr->next==NULL){ + tail=prev; + } + prev -> next = curr -> next; curr -> next = NULL; delete curr; @@ -285,4 +289,4 @@ int main() { return 0; -} \ No newline at end of file +}