@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNegativePositions3() { findElement.find3(new ListNode<Integer>(3), -1); }
public ListNode find3(ListNode listNode, int k) { validateInput(listNode, k); ListNode pointer2 = listNode; for (int i = 0; i <= k; i++) { if (pointer2 == null) { throw new IndexOutOfBoundsException(); } pointer2 = pointer2.getNext(); } ListNode result = listNode; while (pointer2 != null) { result = result.getNext(); pointer2 = pointer2.getNext(); } return result; }
FindKthElement { public ListNode find3(ListNode listNode, int k) { validateInput(listNode, k); ListNode pointer2 = listNode; for (int i = 0; i <= k; i++) { if (pointer2 == null) { throw new IndexOutOfBoundsException(); } pointer2 = pointer2.getNext(); } ListNode result = listNode; while (pointer2 != null) { result = result.getNext(); pointer2 = pointer2.getNext(); } return result; } }
FindKthElement { public ListNode find3(ListNode listNode, int k) { validateInput(listNode, k); ListNode pointer2 = listNode; for (int i = 0; i <= k; i++) { if (pointer2 == null) { throw new IndexOutOfBoundsException(); } pointer2 = pointer2.getNext(); } ListNode result = listNode; while (pointer2 != null) { result = result.getNext(); pointer2 = pointer2.getNext(); } return result; } FindKthElement(); }
FindKthElement { public ListNode find3(ListNode listNode, int k) { validateInput(listNode, k); ListNode pointer2 = listNode; for (int i = 0; i <= k; i++) { if (pointer2 == null) { throw new IndexOutOfBoundsException(); } pointer2 = pointer2.getNext(); } ListNode result = listNode; while (pointer2 != null) { result = result.getNext(); pointer2 = pointer2.getNext(); } return result; } FindKthElement(); ListNode find(ListNode listNode, int k); ListNode find2(ListNode listNode, int k); ListNode find3(ListNode listNode, int k); }
FindKthElement { public ListNode find3(ListNode listNode, int k) { validateInput(listNode, k); ListNode pointer2 = listNode; for (int i = 0; i <= k; i++) { if (pointer2 == null) { throw new IndexOutOfBoundsException(); } pointer2 = pointer2.getNext(); } ListNode result = listNode; while (pointer2 != null) { result = result.getNext(); pointer2 = pointer2.getNext(); } return result; } FindKthElement(); ListNode find(ListNode listNode, int k); ListNode find2(ListNode listNode, int k); ListNode find3(ListNode listNode, int k);  }