From a9cbc06fd745b54b333fb669cb322991da31409f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Apr 2020 16:09:12 +0200 Subject: [PATCH] Update linked_list.cpp --- data_structure/linked_list.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data_structure/linked_list.cpp b/data_structure/linked_list.cpp index dd6536abb..64cad14f9 100644 --- a/data_structure/linked_list.cpp +++ b/data_structure/linked_list.cpp @@ -9,18 +9,18 @@ node *start; void insert(int x) { node *t = start; + node *n = new node; + n->val = x; + n->next = NULL; if (start != NULL) { while (t->next != NULL) { t = t->next; } - node *n = new node; t->next = n; } else { - node *n = new node; start = n; } - n->val = x; - n->next = NULL; + } void remove(int x) {