Leetcode 908 Solution
This article provides solution to leetcode question 908 (middle-of-the-linked-list)
Access this page by simply typing in "lcs 908" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def middleNode(self, head): """ :type head: ListNode :rtype: ListNode """ dummyhead = ListNode(0) dummyhead.next = head fast = dummyhead slow = dummyhead while fast: slow = slow.next fast = fast.next fast = fast.next if fast else None return slow