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..f0ef4c0 --- /dev/null +++ b/linked-list.md @@ -0,0 +1,27 @@ +# Linked list + ++ [Middle of the Linked List](#middle-of-the-linked-list) + +## Middle of the Linked List + +https://leetcode.com/problems/middle-of-the-linked-list/ + +```python +# Definition for singly-linked list. +# class ListNode(object): +# def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution(object): + def middleNode(self, head): + """ + :type head: ListNode + :rtype: ListNode + """ + pastNode = nextNode = head + while nextNode and nextNode.next: + pastNode = pastNode.next + nextNode = nextNode.next.next + return pastNode + +``` \ No newline at end of file