package com.fishercoder.solutions;

import com.fishercoder.common.classes.ListNode;

/**237. Delete Node in a Linked List
 *
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.
*/
public class _237 {

	/**We're not really deleting the node, but we're overwriting this node's value with its successor's value,
	 * and then append its successor's successor to its new successor.
	 * 
	 * In graph, it's like this:
	 * Given this list: 1->2->3->4->null and only access to this to-be-deleted node 3
	 * we overwrite 3 with 4, and then assign null to be 4's next.*/
    public void deleteNode(ListNode node) {
        node.val = node.next.val;
        node.next = node.next.next;
    }

}

@@ -85,16 +85,21 @@
 ;%0D%0A%0D%0A/**
+%0D%0A * 
 237. Del
@@ -127,18 +127,17 @@
 List%0D%0A *
-%0D%0A
+ 
 Write a 
@@ -238,18 +238,19 @@
  node.%0D%0A
-%0D%0A
+ * 
 Supposed
@@ -332,16 +332,20 @@
 value 3,
+%0D%0A *
  the lin
@@ -440,374 +440,8 @@
 %0D%0A%0D%0A
-%09/**We're not really deleting the node, but we're overwriting this node's value with its successor's value,%0D%0A%09 * and then append its successor's successor to its new successor.%0D%0A%09 * %0D%0A%09 * In graph, it's like this:%0D%0A%09 * Given this list: 1-%3E2-%3E3-%3E4-%3Enull and only access to this to-be-deleted node 3%0D%0A%09 * we overwrite 3 with 4, and then assign null to be 4's next.*/%0D%0A
     

refactor 237