@Test public void shouldDeleteSecondToLast() throws Exception { ListNode secondToLast = root.next.next; Solution solution = new Solution(); solution.deleteNode(secondToLast); assertThat(root.val, is(1)); assertThat(root.next.val, is(2)); assertThat(root.next.next.val, is(4)); }
public void deleteNode(ListNode node) { if (node.next == null) { return; } else { node.val = node.next.val; node.next = node.next.next; } }
Solution { public void deleteNode(ListNode node) { if (node.next == null) { return; } else { node.val = node.next.val; node.next = node.next.next; } } }
Solution { public void deleteNode(ListNode node) { if (node.next == null) { return; } else { node.val = node.next.val; node.next = node.next.next; } }  }
Solution { public void deleteNode(ListNode node) { if (node.next == null) { return; } else { node.val = node.next.val; node.next = node.next.next; } }  void deleteNode(ListNode node); }
Solution { public void deleteNode(ListNode node) { if (node.next == null) { return; } else { node.val = node.next.val; node.next = node.next.next; } }  void deleteNode(ListNode node);  }