Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar06 / linkedListCycle.cpp
diff options
context:
space:
mode:
1 files changed, 0 insertions, 33 deletions
-rw-r--r--Seminar06/linkedListCycle.cpp33
diff --git a/Seminar06/linkedListCycle.cpp b/Seminar06/linkedListCycle.cpp
deleted file mode 100644
index 4aa33c6..0000000
--- a/Seminar06/linkedListCycle.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include"../Seminar04/linked-list-utils.h"
-
-bool hasCycle(LinkedListNode<int>* head) {
- LinkedListNode<int> *fast = head;
- LinkedListNode<int> *slow = head;
-
- while (fast && fast->next && slow) {
- fast = (fast->next)->next;
- slow = slow->next;
-
- if (fast == slow)
- return true;
- }
-
- return false;
-}
-
-int main() {
- using Node = LinkedListNode<int>;
-
- Node* last = new Node(6);
-
- Node* list = new Node(1,
- new Node(2,
- new Node(3,
- new Node(4,
- new Node(5,
- last)))));
-
- last->next = list->next->next;
-
- hasCycle(list);
-} \ No newline at end of file