@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullListInstances2() { getTheElementInTheMiddleOfTheList.get2(null); }
public ListNode<Integer> get2(ListNode<Integer> list) { validateInput(list); ListNode<Integer> currentNode = list; ListNode<Integer> fastNode = list.getNext(); while (fastNode != null && fastNode.getNext() != null) { currentNode = currentNode.getNext(); fastNode = fastNode.getNext().getNext(); } return currentNode; }
GetTheElementInTheMiddleOfTheList { public ListNode<Integer> get2(ListNode<Integer> list) { validateInput(list); ListNode<Integer> currentNode = list; ListNode<Integer> fastNode = list.getNext(); while (fastNode != null && fastNode.getNext() != null) { currentNode = currentNode.getNext(); fastNode = fastNode.getNext().getNext(); } return currentNode; } }
GetTheElementInTheMiddleOfTheList { public ListNode<Integer> get2(ListNode<Integer> list) { validateInput(list); ListNode<Integer> currentNode = list; ListNode<Integer> fastNode = list.getNext(); while (fastNode != null && fastNode.getNext() != null) { currentNode = currentNode.getNext(); fastNode = fastNode.getNext().getNext(); } return currentNode; }  }
GetTheElementInTheMiddleOfTheList { public ListNode<Integer> get2(ListNode<Integer> list) { validateInput(list); ListNode<Integer> currentNode = list; ListNode<Integer> fastNode = list.getNext(); while (fastNode != null && fastNode.getNext() != null) { currentNode = currentNode.getNext(); fastNode = fastNode.getNext().getNext(); } return currentNode; }  ListNode<Integer> get(ListNode<Integer> list); ListNode<Integer> get2(ListNode<Integer> list); }
GetTheElementInTheMiddleOfTheList { public ListNode<Integer> get2(ListNode<Integer> list) { validateInput(list); ListNode<Integer> currentNode = list; ListNode<Integer> fastNode = list.getNext(); while (fastNode != null && fastNode.getNext() != null) { currentNode = currentNode.getNext(); fastNode = fastNode.getNext().getNext(); } return currentNode; }  ListNode<Integer> get(ListNode<Integer> list); ListNode<Integer> get2(ListNode<Integer> list);  }