MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / getMid

Method getMid

java/0148-sort-list.java:13–20  ·  view source on GitHub ↗
(ListNode head)

Source from the content-addressed store, hash-verified

11class Solution {
12 // Merge Sort Implementation
13 public ListNode getMid(ListNode head){
14 ListNode slow=head, fast=head.next;
15 while(fast != null && fast.next != null){
16 fast = fast.next.next;
17 slow = slow.next;
18 }
19 return slow;
20 }
21 public ListNode merge(ListNode left, ListNode right){
22 ListNode dummy = new ListNode();
23 ListNode tail = dummy;

Callers 1

sortListMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected