Middle Of The Linked List 🚄 || Beats 100%🔥 || Notes++ || Java, C++, Python
IntuitionApproachComplexityNOTESCode
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
![image.png](https://assets.leetcode.com/users/images/9e624000-f12d-4b1e-997f-40b56223a6a0_1741492869.5769894.png)


# Approach
![image.png](https://assets.leetcode.com/users/images/0a0f1c1f-05ab-4d79-bfcd-85a40998aae6_1741492881.3217247.png)


# Complexity
![image.png](https://assets.leetcode.com/users/images/a61492b7-3e07-4aa8-b451-f60f1f29bf90_1741492816.5820684.png)

# NOTES
![1.jpg](https://assets.leetcode.com/users/images/a544f5f0-211a-4087-928b-5e0b3c532814_1741492838.4343598.jpeg)

# Code
```java []
class Solution {
    public ListNode middleNode(ListNode head) {
        if(head==null || head.next == null) return head;
        ListNode slow=head,fast=head;
        while(fast != null && fast.next != null){
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }
}
```
```c++ []
class Solution {
public:
    ListNode* middleNode(ListNode* head) {
        if (head == nullptr || head->next == nullptr) return head;
        ListNode* slow = head;
        ListNode* fast = head;
        
        while (fast != nullptr && fast->next != nullptr) {
            slow = slow->next;
            fast = fast->next->next;
        }
        return slow;
    }
};
```
```python []
class Solution:
    def middleNode(self, head: ListNode) -> ListNode:
        if not head or not head.next:
            return head
        slow, fast = head, head
        while fast and fast.next:
            slow = slow.next
            fast = fast.next.next
        return slow

```
![ok.png](https://lh6.googleusercontent.com/proxy/c1LeLv7686Z3O0EwMYz1lmGtbXDKOiBX-BuRnwKeGTNuZe0BvX8zRUkiGoFz8uYyPzx4HakbmPxP_Vtd0EUIAPOoej-NiUQub0ONve7eniMitSoN-mHyAeT499TCJF8KA1cTRUiEqyg4MoHYvmeuJGxj-ssy)
['Linked List', 'Python', 'C++', 'Java']