Skip to content

Commit 0ef868b

Browse files
authored
Create LinkedListMiddle.java
1 parent 1a7dace commit 0ef868b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

LinkedListMiddle.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public ListNode middleNode(ListNode head) {
3+
4+
ListNode slow = head, fast = head;
5+
6+
while(fast != null && fast.next != null) {
7+
slow = slow.next;
8+
fast = fast.next.next;
9+
}
10+
11+
return slow;
12+
13+
}
14+
}

0 commit comments

Comments
 (0)