package carack.coding.interview.linkedlist;

import carack.coding.interview.linkedlist.LinkedList.Node;

public class LinkedListQ3 {
   public static void main(String[] args) {
      LinkedList list = new LinkedList();
      list.add(10).add(20).add(30).add(40).add(10).add(20).add(11).add(123);
      deleteMid(list);
   }
   public static void deleteMid(LinkedList list){
      if(list.head == null || list.head.next == null){
         return;
      }
      Node slow = list.head;
      Node fast = list.head.next;
      
      while(fast != null && fast.next != null){
         slow = slow.next;
         fast = fast.next.next;
      }
      
      System.out.println(slow.data);
   }
}
