[C++/Java/Python] Slow and Fast Pointers
Each time, slow go 1 steps while fast go 2 steps.\nWhen fast arrives at the end, slow will arrive right in the middle.\n\nC++:\n\n    ListNode* middleNode(ListN
Each time, `slow` go 1 steps while `fast` go 2 steps.\nWhen `fast` arrives at the end, `slow` will arrive right in the middle.\n\n**C++:**\n```\n    ListNode* middleNode(ListNode* head) {\n        ListNode *slow = head, *fast = head;\n        while (fast && fast->next)\n            slow = slow->next, fast = fast->next->next;\n        return slow;\n    }\n```\n\n**Java:**\n```\n    public ListNode middleNode(ListNode head) {\n        ListNode slow = head, fast = head;\n        while (fast != null && fast.next != null) {\n            slow = slow.next;\n            fast = fast.next.next;\n        }\n        return slow;\n    }\n```\n**Python:**\n```\n    def middleNode(self, head):\n        slow = fast = head\n        while fast and fast.next:\n            slow = slow.next\n            fast = fast.next.next\n        return slow\n```
[]