Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
319 B
0
Indexable
Never
class Solution:
    def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:
        count = 0
        temp = head
        while temp:
            count += 1
            temp = temp.next

        current = head
        for i in range(count // 2):
            current = current.next

        return current
Leave a Comment