explained solution | beginner friendly
\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val = val\n#         self.next = next\ncl
```\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val = val\n#         self.next = next\nclass Solution:\n    def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:\n        #1 we look for the length of the linked list\n        count = 1 #we initialize length at 1 \n        temp = head #because we start at the beginning of the linked list, that is the first value of the list\n        while temp.next : #while temp.next exists = there are still values in linked list\n            count +=1 #length increases by 1\n            temp = temp.next #as we go to the next value \n               \n        #2 we compute the count of the middle\n\t\t#count = number of numbers in the list\n\t\t#If count is even (ex : 6), the real middle would be between 3rd and 4th numbers but we are asked to return the 2nd middle \n\t\t#so we would return 4th, that is the number associated to count = 6//2 + 1 = 3 + 1 = 4\n\t\t#If count is uneven (ex : 5), the middle is 3rd number\n\t\t#so we would return 3rd, that is the number associated to count = 5//2 + 1 = 2 + 1 = 3\n        middle = count//2+1 #since we want either the middle or the second middle, middle is always count//2+1\n        \n        #3 we find the middle node\n        count = 1 #we reinitialize count at 1 \n        temp = head #because we start at the beginning of the linked list, that is the first value\n        while count < middle: #we\'ll stop once count = middle\n            count+=1 #until then, we increase count by one\n            temp = temp.next #as we go to the next value\n        return temp #once we stopped at count = middle, we return temp (the remaining of the linked list)\n```\nUpvote if it helps ! :)
['Python3']