diff --git a/src/leetcode/linked-list.md b/src/leetcode/linked-list.md index 710625b..6267a26 100644 --- a/src/leetcode/linked-list.md +++ b/src/leetcode/linked-list.md @@ -1 +1,18 @@ -# Linked List \ No newline at end of file +# Linked List ++ [Middle of the Linked List](#middle-of-the-linked-list) +## Middle of the Linked List +https://leetcode.com/problems/middle-of-the-linked-list/ +```java +class Solution { + public ListNode middleNode(ListNode head) { + ListNode slow = head; + ListNode fast = head; + while (fast != null && fast.next != null) { + slow = slow.next; + fast = fast.next.next; + } + return slow; + } +} + +```