From d2760d1e5450e488c38688bfa6a6eaa1a1136b5f Mon Sep 17 00:00:00 2001 From: Marian Gusatu <45270790+mariangusatu@users.noreply.github.com> Date: Wed, 22 Apr 2020 11:56:01 +0300 Subject: [PATCH] Update Linked List.cpp fix: reverse check for empty list + converting tabs to spaces --- data_structure/Linked List.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/data_structure/Linked List.cpp b/data_structure/Linked List.cpp index 646d69dc0..49e739a3c 100644 --- a/data_structure/Linked List.cpp +++ b/data_structure/Linked List.cpp @@ -101,15 +101,14 @@ void reverse() { node *first = start; if (first != NULL){ - node *second = first->next; - while (second != NULL) - { - node *tem = second->next; - second->next = first; - first = second; - second = tem; - } - + node *second = first->next; + while (second != NULL) + { + node *tem = second->next; + second->next = first; + first = second; + second = tem; + } start->next = NULL; start = first; }