diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/SinglyLinkedListWarmUp.iml b/.idea/SinglyLinkedListWarmUp.iml new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/.idea/SinglyLinkedListWarmUp.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..226ca24 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..077e3e0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.cpp b/main.cpp index b26f302..36c090c 100644 --- a/main.cpp +++ b/main.cpp @@ -37,7 +37,16 @@ class SinglyLinkedList { void reverseLinkedList() { // TODO: Students will implement this function - std::cout << "Implement reverseLinkedList()" << std::endl; + Node* prev = nullptr; + Node* curr = head; + + while (curr != nullptr) { + Node* next = curr->next; + curr->next = prev; + prev = curr; + curr = next; + } + head = prev; } }; diff --git a/main.exe b/main.exe new file mode 100644 index 0000000..827b108 Binary files /dev/null and b/main.exe differ