Last active
April 8, 2020 07:13
-
-
Save munguial/11cb4de08a1898a53be6f2dbb90f7da4 to your computer and use it in GitHub Desktop.
Day 8 - Middle of the linked list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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