Skip to content

Instantly share code, notes, and snippets.

@munguial
Last active April 8, 2020 07:13
Show Gist options
  • Save munguial/11cb4de08a1898a53be6f2dbb90f7da4 to your computer and use it in GitHub Desktop.
Save munguial/11cb4de08a1898a53be6f2dbb90f7da4 to your computer and use it in GitHub Desktop.
Day 8 - Middle of the linked list
# https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/529/week-2/3290/
class Solution:
def middleNode(self, head: ListNode) -> ListNode:
slow = head
fast = head
while fast:
fast = fast.next
if not fast:
break
fast = fast.next
slow = slow.next
return slow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment