diff --git a/README.md b/README.md deleted file mode 100644 index 7c3b229..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Algorithms 2019-2020 Python LEETCODE - -Check branches for information. \ No newline at end of file diff --git a/linked-list.md b/linked-list.md new file mode 100644 index 0000000..c5172a3 --- /dev/null +++ b/linked-list.md @@ -0,0 +1,31 @@ +# Linked list + ++ [Linked List Cycle II](#linked-list-cycle-ii) + +## Linked List Cycle II + +https://leetcode.com/problems/linked-list-cycle-ii/ + +```python +# Definition for singly-linked list. +# class ListNode(object): +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution(object): + def detectCycle(self, _head): + tail = curNode = head = _head + while curNode and curNode.next: + tail = tail.next + curNode = curNode.next.next + if tail is curNode: + break + else: + return None + while head is not tail: + tail = tail.next + head = head.next + return head + +``` \ No newline at end of file