예제 #1
0
        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;
        }
예제 #2
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);
        }
예제 #3
0
 public CheckLinkedNode(LinkedNode <T> linkedNode) : base(linkedNode.Value)
 {
     this.Next = new CheckLinkedNode <T>(linkedNode.Next);
 }