public static LinkedList doLinkedListInsertAtMedianint numIt
public static LinkedList<Integer> doLinkedListInsertAtMedian(int numItems) {
        System.out.print(\"doLinkedListInsertAtMedian: \");
        LinkedList<Integer> list = new LinkedList<>();
       // TODO Write code that adds integers 0 through (numitems - 1)
        // to list, inside a loop.
       
        for(int i=0; i<numItems-1; i++){
        list.add(i);
        }
long startTime = getTimestamp();
       // TODO Write code that adds -1 to list at index
        // (list.size() / 2)
   
       
        long endTime = getTimestamp();
        long totalTime = endTime - startTime;
        System.out.println(totalTime);
       
        return list;
    }
I need help on that 2nd //TODO comment. Any help is appreciated, thank you.
Solution
Hi,
I have implemented requred area. Please find the below updated code.
public static LinkedList<Integer> doLinkedListInsertAtMedian(int numItems) {
        System.out.print(\"doLinkedListInsertAtMedian: \");
        LinkedList<Integer> list = new LinkedList<>();
       // TODO Write code that adds integers 0 through (numitems - 1)
        // to list, inside a loop.
       
        for(int i=0; i<numItems-1; i++){
        list.add(i);
        }
long startTime = getTimestamp();
       // TODO Write code that adds -1 to list at index
        // (list.size() / 2)
           int index = list.size()/2;
        list.add(index , -1);
      
        long endTime = getTimestamp();
        long totalTime = endTime - startTime;
        System.out.println(totalTime);
       
        return list;
    }

