public static void DeleteNode(LinkedNode <int> node) { if (node.Next == null) { throw new NotImplementedException(); } node.Value = node.Next.Value; node.Next = node.Next.Next; node.Next = null; node.Value = 0; }
//Check null values public static LinkedNode <int> AddLinkedList(LinkedNode <int> first, LinkedNode <int> second) { if (first.Next == null && second.Next == null) { return(new LinkedNode <int>(first.Value + second.Value)); } var tail = AddLinkedList(first?.Next, second?.Next); var result = new LinkedNode <int>(first.Value + second.Value + tail.Value / 10); tail.Value = tail.Value % 10; result.Next = tail; return(result); }
public CheckLinkedNode(LinkedNode <T> linkedNode) : base(linkedNode.Value) { this.Next = new CheckLinkedNode <T>(linkedNode.Next); }