https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/



Runtime: 2573 ms, faster than 51.05% of Python3 online submissions for Delete the Middle Node of a Linked List.

Memory Usage: 60.8 MB, less than 7.77% of Python3 online submissions for Delete the Middle Node of a Linked List.



```python
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def deleteMiddle(self, head: Optional[ListNode]) -> Optional[ListNode]:
        #15:20
        length = 0
        node = head
        while node:
            node = node.next
            length += 1
            
        if (length == 0):
            return head
        if (length == 1):
            return None
        
        middleIndex = length // 2 - 1
        node = head
        index = -1
        while node:
            index += 1
            if (index == middleIndex and node.next != None):
                node.next = node.next.next
                break
            node = node.next
        
        return head
        #15:25
```
