Skip to content

Instantly share code, notes, and snippets.

@thekhairul
Created May 19, 2022 05:11
Show Gist options
  • Save thekhairul/a918612df1a3e5538906d4044a1d66b9 to your computer and use it in GitHub Desktop.
Save thekhairul/a918612df1a3e5538906d4044a1d66b9 to your computer and use it in GitHub Desktop.
Leetcode 2095: Delete the Middle Node of a Linked List - python
def deleteMiddle(head):
if head.next:
slow = head
fast = head
beforeMid = None
while fast and fast.next:
fast = fast.next.next
beforeMid = slow
slow = slow.next
beforeMid.next = slow.next
return head
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment