Python/JS/Java/Go/C++ O(n) by two-pointers  [w/ Diagram] 有中文解題文章
O(n) by two-pointers\n\n\u4E2D\u6587\u89E3\u984C\u6587\u7AE0\n\n---\n\nHint:\n\nThink of two pointers technique with slow runner and fast runner.\n\nBoth slow r
O(n) by two-pointers\n\n[\u4E2D\u6587\u89E3\u984C\u6587\u7AE0](https://vocus.cc/article/6588e890fd89780001c3f462)\n\n---\n\n**Hint**:\n\nThink of **two pointers** technique with **slow runner** and **fast runner**.\n\nBoth slow runner and fast runner are initialized to head node.\n\nEach iteration, **fast runner moves two steps forward** while the **slow one moves one steps only**.\n\nWhen fast runner meets the empty node (i.e., NULL) on the tail, the slow one will be right on the node of midpoint.\n\n---\n\n**Abstract model**:\n![image](https://assets.leetcode.com/users/brianchiang_tw/image_1583131878.png)\n\n\n---\n\n**Implementation**:\n\n```Python []\nclass Solution:\n    def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:\n\n        slow = fast = head\n\n        while fast and fast.next:\n\n            fast = fast.next.next\n            slow = slow.next\n\n        return slow\n```\n```Javascript []\nvar middleNode = function(head) {\n    let [slow, fast] = [head, head];\n\n    while( fast && fast.next){\n        fast = fast.next.next;\n        slow = slow.next;\n    }\n    return slow;\n};\n```\n```Java []\nclass Solution {\n    public ListNode middleNode(ListNode head) {\n        ListNode slow=head, fast=head;\n\n        while( fast != null && fast.next != null ){\n            fast = fast.next.next;\n            slow = slow.next;\n        }\n        return slow;\n    }\n}\n```\n```C++ []\nclass Solution {\npublic:\n    ListNode* middleNode(ListNode* head) {\n        ListNode *slow = head, *fast = head;\n\n        while( fast != NULL && fast->next != NULL){\n            fast = fast->next->next;\n            slow = slow->next;\n        }\n        return slow;\n    }\n};\n```\n```Go []\nfunc middleNode(head *ListNode) *ListNode {\n    \n    slow, fast := head, head\n\n    for(  fast != nil && fast.Next != nil ) {\n        fast = fast.Next.Next\n        slow = slow.Next\n    }\n    return slow\n}\n```\n\n\n---\n\nRelated leetcode challenge:\n\n[Leetcode #141 Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/)\n\n[Leetcode #328 Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/)
['Linked List', 'Two Pointers', 'C', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']