We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b4c8c1f commit 77fc206Copy full SHA for 77fc206
LL/876.md
@@ -0,0 +1,33 @@
1
+## Middle of the Linked List
2
+
3
+#### Description
4
5
+[link](https://leetcode.com/problems/middle-of-the-linked-list/)
6
7
+---
8
9
+#### Solution
10
11
+- See Code
12
13
14
15
+#### Code
16
17
+O(n)
18
19
+```python
20
+# Definition for singly-linked list.
21
+# class ListNode:
22
+# def __init__(self, val=0, next=None):
23
+# self.val = val
24
+# self.next = next
25
+class Solution:
26
+ def middleNode(self, head: ListNode) -> ListNode:
27
+ fast = head
28
+ slow = head
29
+ while fast.next and fast.next.next:
30
+ slow = slow.next
31
+ fast = fast.next.next
32
+ return slow .next if fast.next else slow
33
+```
0 commit comments