Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 322 Bytes

File metadata and controls

18 lines (14 loc) · 322 Bytes

Middle of the Linked List

Solution 1

class Solution {
    public ListNode middleNode(ListNode head) {
        ListNode slow = head, fast = head;

        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
        }

        return slow;
    }
}