-
Notifications
You must be signed in to change notification settings - Fork 0
LC 0876 [E] Middle of the Linked List
Code with Senpai edited this page May 19, 2022
·
1 revision
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:
fast = head
slow = head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
return slow
footer